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 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 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 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 ); }