@Test( expected = SQLFeatureNotSupportedException.class ) public void testSetTransactionIsolationReadUncommittedThrows() throws SQLException { try { connection.setTransactionIsolation( TRANSACTION_READ_UNCOMMITTED ); } catch ( SQLFeatureNotSupportedException e ) { // Check a few things in an error message: assertThat( "Missing requested-level string", e.getMessage(), containsString( "TRANSACTION_READ_UNCOMMITTED" ) ); assertThat( "Missing (or reworded) expected description", e.getMessage(), containsString( "transaction isolation level" ) ); assertThat( "Missing current-level string", e.getMessage(), containsString( "TRANSACTION_NONE" ) ); throw e; } }
protected boolean executeImpl(Env env) throws SQLException { if (getStatementType() == StatementType.INSERT) { try { return _stmt.execute(_query, Statement.RETURN_GENERATED_KEYS); } catch (SQLFeatureNotSupportedException e) { log.log(Level.FINE, e.getMessage(), e); return _stmt.execute(_query); } } else { return _stmt.execute(_query); } }
public int executePreparedStatement(PreparedStatement preparedStatement, boolean reusedStatement, boolean collectGeneratedKeys) throws SQLException { final int result = executePreparedStatement(preparedStatement); if (collectGeneratedKeys && isGeneratedKeysCollectionEnabled()) { try { final ResultSet generatedKeysResultSet = preparedStatement.getGeneratedKeys(); try { while (generatedKeysResultSet.next()) { final Object key = generatedKeysResultSet.getObject(1); getUpdateSummaryBuilder().addGeneratedKey(key); } } finally { FileHelper.safeClose(generatedKeysResultSet); } } catch (SQLFeatureNotSupportedException e) { // ignore logger.debug("Getting generated keys from JDBC statement is not supported by driver: {}", e .getMessage(), e); } catch (SQLException | RuntimeException e) { logger.warn("Failed to get generated keys from JDBC statement: {}", e.getMessage(), e); } } if (!reusedStatement) { closePreparedStatement(preparedStatement); } return result; }
public int executePreparedStatement(PreparedStatement preparedStatement, boolean reusedStatement, boolean collectGeneratedKeys) throws SQLException { final int result = executePreparedStatement(preparedStatement); if (collectGeneratedKeys && isGeneratedKeysCollectionEnabled()) { try { final ResultSet generatedKeysResultSet = preparedStatement.getGeneratedKeys(); try { while (generatedKeysResultSet.next()) { final Object key = generatedKeysResultSet.getObject(1); getUpdateSummaryBuilder().addGeneratedKey(key); } } finally { FileHelper.safeClose(generatedKeysResultSet); } } catch (SQLFeatureNotSupportedException e) { // ignore logger.debug("Getting generated keys from JDBC statement is not supported by driver: {}", e .getMessage(), e); } catch (SQLException | RuntimeException e) { logger.warn("Failed to get generated keys from JDBC statement: {}", e.getMessage(), e); } } if (!reusedStatement) { closePreparedStatement(preparedStatement); } return result; }
@Test( expected = SQLFeatureNotSupportedException.class ) public void testSetTransactionIsolationReadUncommittedThrows() throws SQLException { try { getConnection().setTransactionIsolation( TRANSACTION_READ_UNCOMMITTED ); } catch ( SQLFeatureNotSupportedException e ) { // Check a few things in an error message: assertThat( "Missing requested-level string", e.getMessage(), containsString( "TRANSACTION_READ_UNCOMMITTED" ) ); assertThat( "Missing (or reworded) expected description", e.getMessage(), containsString( "transaction isolation level" ) ); assertThat( "Missing current-level string", e.getMessage(), containsString( "TRANSACTION_NONE" ) ); throw e; } }