private ConnectionProvider buildConnectionProvider(DataSource dataSource, Map<String, String> properties) { final DatasourceConnectionProviderImpl connectionProvider = new DatasourceConnectionProviderImpl(); connectionProvider.setDataSource(dataSource); connectionProvider.configure(properties); return connectionProvider; }
public ConnectionCreator build() { if ( driver == null ) { return new DriverManagerConnectionCreator( serviceRegistry, url, connectionProps, autoCommit, isolation ); } else { return new DriverConnectionCreator( driver, serviceRegistry, url, connectionProps, autoCommit, isolation ); } } }
private static DriverManagerConnectionProviderImpl buildConnectionProvider(Properties props, final boolean allowAggressiveRelease) { DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl() { public boolean supportsAggressiveRelease() { return allowAggressiveRelease; } }; connectionProvider.configure( props ); return connectionProvider; }
/** * @deprecated Use {@link ConnectionProviderInitiator#toIsolationNiceName} instead */ @Deprecated public static String isolationLevelToString(int isolation) { return ConnectionProviderInitiator.toIsolationNiceName( isolation ); }
public Connection getConnection() throws SQLException { startIfNeeded(); statelock.readLock().lock(); try { return pool.poll(); } finally { statelock.readLock().unlock(); } }
public void closeConnection(Connection conn) throws SQLException { if (conn == null) { return; } startIfNeeded(); statelock.readLock().lock(); try { pool.add( conn ); } finally { statelock.readLock().unlock(); } } }
@Override public void configure(Map configurationValues) { log.usingHibernateBuiltInConnectionPool(); PooledConnections pool = buildPool( configurationValues, serviceRegistry ); final long validationInterval = ConfigurationHelper.getLong( VALIDATION_INTERVAL, configurationValues, 30 ); PoolState newstate = new PoolState( pool, validationInterval ); this.state = newstate; }
@Override public void stop() { delegate.stop(); }
@Override public void closeConnection(Connection conn) throws SQLException { state.closeConnection( conn ); }
public PooledConnections build() { return new PooledConnections( this ); } }
@Override public Connection getConnection() throws SQLException { return state.getConnection(); }
@Override public void stop() { state.stop(); }
public String getUrl() { return connectionCreator.getUrl(); }
@Override protected Connection makeConnection(String url, Properties connectionProps) { try { return DriverManager.getConnection( url, connectionProps ); } catch (SQLException e) { throw convertSqlException( "Error calling DriverManager#getConnection", e ); } } }
@Override protected Connection makeConnection(String url, Properties connectionProps) { try { return driver.connect( url, connectionProps ); } catch (SQLException e) { throw convertSqlException( "Error calling Driver#connect", e ); } } }
protected void addConnections(int numberOfConnections) { for ( int i = 0; i < numberOfConnections; i++ ) { Connection connection = connectionCreator.createConnection(); allConnections.add( connection ); availableConnections.add( connection ); } }
@Override public void closeConnection(Connection conn) throws SQLException { super.closeConnection( conn ); openConnection--; }
@Override public Connection getConnection() throws SQLException { openConnection++; return super.getConnection(); }
@Override public <T> T unwrap(Class<T> unwrapType) { return delegate.unwrap( unwrapType ); }
@Override public boolean isUnwrappableAs(Class unwrapType) { return delegate.isUnwrappableAs( unwrapType ); }