@Override public void releaseConnection(Connection connection) throws SQLException { connectionProvider.closeConnection( connection ); }
@Override public void closeConnection(Connection conn) throws SQLException { connectionProvider.closeConnection( conn ); }
@Override public void releaseConnection(Connection connection) throws SQLException { connectionProvider.closeConnection( connection ); }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { sqlExceptionHelper.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
@Override public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException { selectConnectionProvider( tenantIdentifier ).closeConnection( connection ); }
@Override protected void done() throws Throwable { cp.closeConnection( connectionUnderTest ); }
@Override public void releaseAnyConnection(Connection connection) throws SQLException { getAnyConnectionProvider().closeConnection( connection ); }
@Override public void releaseConnection(Connection connection) throws SQLException { if ( connection != this.jdbcConnection ) { throw new PersistenceException( String.format( "Connection [%s] passed back to %s was not the one obtained [%s] from it", connection, JdbcConnectionAccessConnectionProviderImpl.class.getName(), jdbcConnection ) ); } // Reset auto-commit if ( !wasInitiallyAutoCommit ) { try { if ( jdbcConnection.getAutoCommit() ) { jdbcConnection.setAutoCommit( false ); } } catch (SQLException e) { log.info( "Was unable to reset JDBC connection to no longer be in auto-commit mode" ); } } // Release the connection connectionProvider.closeConnection( jdbcConnection ); }
@Override public void releaseConnection(Connection connection) throws SQLException { try { listener.jdbcConnectionReleaseStart(); connectionProvider.closeConnection( connection ); } finally { listener.jdbcConnectionReleaseEnd(); } }
private void releaseConnection() throws SQLException { if ( connection != null ) { try { serviceRegistry.getService( JdbcEnvironment.class ).getSqlExceptionHelper().logAndClearWarnings( connection ); } finally { try { serviceRegistry.getService( ConnectionProvider.class ).closeConnection( connection ); } finally { connection = null; } } } }
@Test public void testSettingIsolationAsNumericString() throws Exception { Properties properties = Environment.getProperties(); augmentConfigurationSettings( properties ); properties.put( AvailableSettings.ISOLATION, Integer.toString( Connection.TRANSACTION_SERIALIZABLE ) ); ConnectionProvider provider = getConnectionProviderUnderTest(); try { ( (Configurable) provider ).configure( properties ); if ( Startable.class.isInstance( provider ) ) { ( (Startable) provider ).start(); } Connection connection = provider.getConnection(); assertEquals( Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation() ); provider.closeConnection( connection ); } finally { ( (Stoppable) provider ).stop(); } }
@Override public void releaseConnection(Connection connection) throws SQLException { if ( !settings.getMultiTenancyStrategy().requiresMultiTenantConnectionProvider() ) { serviceRegistry.getService( ConnectionProvider.class ).closeConnection( connection ); } else { serviceRegistry.getService( MultiTenantConnectionProvider.class ).releaseAnyConnection( connection ); } }
public void prepare(boolean allowAggressiveRelease) throws SQLException { dialect = ConnectionProviderBuilder.getCorrespondingDialect(); connectionProvider = ConnectionProviderBuilder.buildConnectionProvider( allowAggressiveRelease ); sqlStatementLogger = new SqlStatementLogger( true, false ); Connection jdbcConnection = connectionProvider.getConnection(); try { jdbcEnvironment = new JdbcEnvironmentImpl( jdbcConnection.getMetaData(), dialect ); } finally { try { connectionProvider.closeConnection( jdbcConnection ); } catch (SQLException ignore) { } } this.jdbcConnectionAccess = new JdbcConnectionAccessImpl( connectionProvider ); }
@Test public void testSettingIsolationAsName() throws Exception { Properties properties = Environment.getProperties(); augmentConfigurationSettings( properties ); properties.put( AvailableSettings.ISOLATION, "TRANSACTION_SERIALIZABLE" ); ConnectionProvider provider = getConnectionProviderUnderTest(); try { ( (Configurable) provider ).configure( properties ); if ( Startable.class.isInstance( provider ) ) { ( (Startable) provider ).start(); } Connection connection = provider.getConnection(); assertEquals( Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation() ); provider.closeConnection( connection ); } finally { ( (Stoppable) provider ).stop(); } }
@Test public void testSettingIsolationAsNameAlt() throws Exception { Properties properties = Environment.getProperties(); augmentConfigurationSettings( properties ); properties.put( AvailableSettings.ISOLATION, "SERIALIZABLE" ); ConnectionProvider provider = getConnectionProviderUnderTest(); try { ( (Configurable) provider ).configure( properties ); if ( Startable.class.isInstance( provider ) ) { ( (Startable) provider ).start(); } Connection connection = provider.getConnection(); assertEquals( Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation() ); provider.closeConnection( connection ); } finally { ( (Stoppable) provider ).stop(); } } }
@Test public void testSettingIsolationAsNumeric() throws Exception { Properties properties = Environment.getProperties(); augmentConfigurationSettings( properties ); properties.put( AvailableSettings.ISOLATION, Connection.TRANSACTION_SERIALIZABLE ); ConnectionProvider provider = getConnectionProviderUnderTest(); try { ( (Configurable) provider ).configure( properties ); if ( Startable.class.isInstance( provider ) ) { ( (Startable) provider ).start(); } Connection connection = provider.getConnection(); assertEquals( Connection.TRANSACTION_SERIALIZABLE, connection.getTransactionIsolation() ); provider.closeConnection( connection ); } finally { ( (Stoppable) provider ).stop(); } }
if ( conn != null ) { try { connectionProvider.closeConnection( conn );
@Override protected void prepareTest() throws Exception { super.prepareTest(); try { Connection conn = cp.getConnection(); try { final GenerationTargetToDatabase target = new GenerationTargetToDatabase( new DdlTransactionIsolatorTestingImpl( serviceRegistry(), conn ), true ); new SchemaCreatorImpl( serviceRegistry() ).doCreation( metadata(), false, target ); } finally { cp.closeConnection( conn ); } } catch( Throwable ignore ) { } }
@Override protected void cleanupTest() throws Exception { try { Connection conn = cp.getConnection(); try { final GenerationTargetToDatabase target = new GenerationTargetToDatabase( new DdlTransactionIsolatorTestingImpl( serviceRegistry(), conn ), true ); new SchemaDropperImpl( serviceRegistry() ).doDrop( metadata(), false, target ); } finally { cp.closeConnection( conn ); } } catch( Throwable ignore ) { } super.cleanupTest(); } }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { sqlExceptionHelper.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }