private final DataSource delegate;
public ConnectionPoolDataSource(DataSource underlyingDataSource) {
Preconditions.checkArgument(underlyingDataSource != null, "underlyingDataSource is null");
ConnectionFactory connectionFactory = new ConfiguringConnectionFactory(underlyingDataSource);
GenericObjectPool objectPool = new GenericObjectPool();
objectPool.setTestOnBorrow(false);
objectPool.setTestOnReturn(false);
objectPool.setTestWhileIdle(true);
objectPool.setTimeBetweenEvictionRunsMillis(60 * 1000L);
PoolableObjectFactory factory = new PoolableConnectionFactory(connectionFactory, objectPool, null,
"SELECT 1", false, false);
objectPool.setFactory(factory);
delegate = new PoolingDataSource(objectPool);
}