public void closeConnection(Connection conn) throws SQLException { if (conn == null) { return; } startIfNeeded(); statelock.readLock().lock(); try { pool.add( conn ); } finally { statelock.readLock().unlock(); } } }
public Connection poll() throws SQLException { Connection conn = availableConnections.poll(); if ( conn == null ) { synchronized (allConnections) { if(allConnections.size() < maxSize) { addConnections( 1 ); return poll(); } } throw new HibernateException( "The internal connection pool has reached its maximum size and no connection is currently available!" ); } conn.setAutoCommit( autoCommit ); return conn; }
public void stop() { statelock.writeLock().lock(); try { if ( !active ) { return; } log.cleaningUpConnectionPool( pool.getUrl() ); active = false; if ( executorService != null ) { executorService.shutdown(); } executorService = null; try { pool.close(); } catch (SQLException e) { log.unableToClosePooledConnection( e ); } } finally { statelock.writeLock().unlock(); } }
public void stop() { statelock.writeLock().lock(); try { if ( !active ) { return; } log.cleaningUpConnectionPool( pool.getUrl() ); active = false; if ( executorService != null ) { executorService.shutdown(); } executorService = null; try { pool.close(); } catch (SQLException e) { log.unableToClosePooledConnection( e ); } } finally { statelock.writeLock().unlock(); } }
public void validate() { final int size = size(); if ( !primed && size >= minSize ) { // IMPL NOTE : the purpose of primed is to allow the pool to lazily reach its // defined min-size. log.debug( "Connection pool now considered primed; min-size will be maintained" ); primed = true; } if ( size < minSize && primed ) { int numberToBeAdded = minSize - size; log.debugf( "Adding %s Connections to the pool", numberToBeAdded ); addConnections( numberToBeAdded ); } else if ( size > maxSize ) { int numberToBeRemoved = size - maxSize; log.debugf( "Removing %s Connections from the pool", numberToBeRemoved ); removeConnections( numberToBeRemoved ); } }
public void closeConnection(Connection conn) throws SQLException { if (conn == null) { return; } startIfNeeded(); statelock.readLock().lock(); try { pool.add( conn ); } finally { statelock.readLock().unlock(); } } }
public Connection poll() throws SQLException { Connection conn = availableConnections.poll(); if ( conn == null ) { synchronized (allConnections) { if(allConnections.size() < maxSize) { addConnections( 1 ); return poll(); } } throw new HibernateException( "The internal connection pool has reached its maximum size and no connection is currently available!" ); } conn.setAutoCommit( autoCommit ); return conn; }
public PooledConnections build() { return new PooledConnections( this ); } }
private PooledConnections( Builder builder) { log.debugf( "Initializing Connection pool with %s Connections", builder.initialSize ); connectionCreator = builder.connectionCreator; autoCommit = builder.autoCommit; maxSize = builder.maxSize; minSize = builder.minSize; log.hibernateConnectionPoolSize( maxSize, minSize ); addConnections( builder.initialSize ); }
public Connection getConnection() throws SQLException { startIfNeeded(); statelock.readLock().lock(); try { return pool.poll(); } finally { statelock.readLock().unlock(); } }
public void close() throws SQLException { try { int allocationCount = allConnections.size() - availableConnections.size(); if(allocationCount > 0) { log.error( "Connection leak detected: there are " + allocationCount + " unclosed connections upon shutting down pool " + getUrl()); } } finally { for ( Connection connection : allConnections ) { connection.close(); } } }
public void validate() { final int size = size(); if ( !primed && size >= minSize ) { // IMPL NOTE : the purpose of primed is to allow the pool to lazily reach its // defined min-size. log.debug( "Connection pool now considered primed; min-size will be maintained" ); primed = true; } if ( size < minSize && primed ) { int numberToBeAdded = minSize - size; log.debugf( "Adding %s Connections to the pool", numberToBeAdded ); addConnections( numberToBeAdded ); } else if ( size > maxSize ) { int numberToBeRemoved = size - maxSize; log.debugf( "Removing %s Connections from the pool", numberToBeRemoved ); removeConnections( numberToBeRemoved ); } }
private PooledConnections( Builder builder) { log.debugf( "Initializing Connection pool with %s Connections", builder.initialSize ); connectionCreator = builder.connectionCreator; autoCommit = builder.autoCommit; maxSize = builder.maxSize; minSize = builder.minSize; log.hibernateConnectionPoolSize( maxSize, minSize ); addConnections( builder.initialSize ); }
public PooledConnections build() { return new PooledConnections( this ); } }
public void close() throws SQLException { try { int allocationCount = allConnections.size() - availableConnections.size(); if(allocationCount > 0) { log.error( "Connection leak detected: there are " + allocationCount + " unclosed connections upon shutting down pool " + getUrl()); } } finally { for ( Connection connection : allConnections ) { connection.close(); } } }
public Connection getConnection() throws SQLException { startIfNeeded(); statelock.readLock().lock(); try { return pool.poll(); } finally { statelock.readLock().unlock(); } }