use of org.apache.commons.pool2.ObjectPool in project spring-framework by spring-projects.
the class CommonsPool2TargetSource method createObjectPool.
/**
* Subclasses can override this if they want to return a specific Commons pool.
* They should apply any configuration properties to the pool here.
* <p>Default is a GenericObjectPool instance with the given pool size.
* @return an empty Commons {@code ObjectPool}.
* @see GenericObjectPool
* @see #setMaxSize
*/
protected ObjectPool createObjectPool() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(getMaxSize());
config.setMaxIdle(getMaxIdle());
config.setMinIdle(getMinIdle());
config.setMaxWaitMillis(getMaxWait());
config.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
config.setBlockWhenExhausted(isBlockWhenExhausted());
return new GenericObjectPool(this, config);
}
use of org.apache.commons.pool2.ObjectPool in project zeppelin by apache.
the class JDBCInterpreter method createConnectionPool.
private void createConnectionPool(String url, String user, String propertyKey, Properties properties) throws SQLException, ClassNotFoundException {
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, properties);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);
poolableConnectionFactory.setPool(connectionPool);
Class.forName(properties.getProperty(DRIVER_KEY));
PoolingDriver driver = new PoolingDriver();
driver.registerPool(propertyKey + user, connectionPool);
getJDBCConfiguration(user).saveDBDriverPool(propertyKey, driver);
}
Aggregations