@Override public Connection getIsolatedConnection() { try { return jdbcContext.getJdbcConnectionAccess().obtainConnection(); } catch (SQLException e) { // should never happen throw new SchemaManagementException( "Error accessing user-provided Connection via JdbcConnectionAccessProvidedConnectionImpl", e ); } }
@Override public Connection getJdbcConnection() { if ( jdbcConnection == null ) { try { jdbcConnection = jdbcConnectionAccess.obtainConnection(); } catch (SQLException e) { throw jdbcEnvironment.getSqlExceptionHelper().convert( e, "Unable to obtain JDBC Connection" ); } } return jdbcConnection; }
Connection connection = connectionAccess.obtainConnection();
Connection connection; try { connection = connectionAccess.obtainConnection();
private Connection acquireConnectionIfNeeded() { if ( physicalConnection == null ) { // todo : is this the right place for these observer calls? observer.jdbcConnectionAcquisitionStart(); try { physicalConnection = jdbcConnectionAccess.obtainConnection(); } catch (SQLException e) { throw sqlExceptionHelper.convert( e, "Unable to acquire JDBC Connection" ); } finally { observer.jdbcConnectionAcquisitionEnd( physicalConnection ); } } return physicalConnection; }
try (Connection connection = ssr.getService( JdbcServices.class ) .getBootstrapJdbcConnectionAccess() .obtainConnection(); Statement statement = connection.createStatement()) { connection.setAutoCommit( true );
if ( jdbcConnection == null ) { try { this.jdbcConnection = jdbcContext.getJdbcConnectionAccess().obtainConnection();
@Override protected void cleanupTest() throws Exception { Connection connection = null; Statement stmnt = null; try { connection = services.getBootstrapJdbcConnectionAccess().obtainConnection(); stmnt = connection.createStatement(); stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" ); } finally { if ( stmnt != null ) { try { stmnt.close(); } catch ( SQLException ignore ) { } } if ( connection != null ) { try { services.getBootstrapJdbcConnectionAccess().releaseConnection( connection ); } catch ( SQLException ignore ) { } } } services.release(); }
@Override protected void prepareTest() throws Exception { services.prepare( true ); Connection connection = null; Statement stmnt = null; try { connection = services.getBootstrapJdbcConnectionAccess().obtainConnection(); stmnt = connection.createStatement(); stmnt.execute( "drop table SANDBOX_JDBC_TST if exists" ); stmnt.execute( "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" ); } finally { if ( stmnt != null ) { try { stmnt.close(); } catch ( SQLException ignore ) { } } if ( connection != null ) { try { services.getBootstrapJdbcConnectionAccess().releaseConnection( connection ); } catch ( SQLException ignore ) { } } } }
boolean wasAutoCommit = false; try { Connection connection = jdbcConnectionAccess().obtainConnection(); try { if ( transacted ) {
final JdbcConnectionAccess jdbcConnectionAccess = buildJdbcConnectionAccess( configurationValues, registry ); try { final Connection connection = jdbcConnectionAccess.obtainConnection(); try { final DatabaseMetaData dbmd = connection.getMetaData();
protected boolean isSerializableIsolationEnforced() throws Exception { JdbcConnectionAccess connectionAccess = sessionFactory().getServiceRegistry().getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess(); Connection conn = null; try { conn = connectionAccess.obtainConnection(); return conn.getTransactionIsolation() >= Connection.TRANSACTION_SERIALIZABLE; } finally { if ( conn != null ) { try { connectionAccess.releaseConnection( conn ); } catch ( Throwable ignore ) { // ignore... } } } }
this.jdbcConnection = jdbcContext.getJdbcConnectionAccess().obtainConnection();
.build(); try (Connection connection = ssr.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection(); Statement statement = connection.createStatement()) { connection.setAutoCommit( true ); log.debug( e.getMessage() ); try (Connection connection = ssr.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection(); Statement statement = connection.createStatement()) { connection.setAutoCommit( true );
private <T> T doTheWork(WorkExecutorVisitable<T> work) { try { // obtain our isolated connection Connection connection = jdbcConnectionAccess().obtainConnection(); try { // do the actual work return work.accept( new WorkExecutor<T>(), connection ); } catch (HibernateException e) { throw e; } catch (Exception e) { throw new HibernateException( "Unable to perform isolated work", e ); } finally { try { // no matter what, release the connection (handle) jdbcConnectionAccess().releaseConnection( connection ); } catch (Throwable ignore) { LOG.unableToReleaseIsolatedConnection( ignore ); } } } catch (SQLException e) { throw sqlExceptionHelper().convert( e, "unable to obtain isolated JDBC connection" ); } }
@Override public Connection getIsolatedConnection() { try { return jdbcContext.getJdbcConnectionAccess().obtainConnection(); } catch (SQLException e) { // should never happen throw new SchemaManagementException( "Error accessing user-provided Connection via JdbcConnectionAccessProvidedConnectionImpl", e ); } }
@Override public Connection getJdbcConnection() { if ( jdbcConnection == null ) { try { jdbcConnection = jdbcConnectionAccess.obtainConnection(); } catch (SQLException e) { throw jdbcEnvironment.getSqlExceptionHelper().convert( e, "Unable to obtain JDBC Connection" ); } } return jdbcConnection; }
@Override public IsolationDelegate createIsolationDelegate() { Connection connection = mock(Connection.class); JdbcConnectionAccess jdbcConnectionAccess = mock(JdbcConnectionAccess.class); try { when(jdbcConnectionAccess.obtainConnection()).thenReturn(connection); } catch (SQLException e) { } return new JtaIsolationDelegate(jdbcConnectionAccess, mock(SqlExceptionHelper.class), tm); }
private Connection acquireConnectionIfNeeded() { if ( physicalConnection == null ) { // todo : is this the right place for these observer calls? observer.jdbcConnectionAcquisitionStart(); try { physicalConnection = jdbcConnectionAccess.obtainConnection(); } catch (SQLException e) { throw sqlExceptionHelper.convert( e, "Unable to acquire JDBC Connection" ); } finally { observer.jdbcConnectionAcquisitionEnd( physicalConnection ); } } return physicalConnection; }