* @param database The database type.
* @return A high performance connection pool datasource.
*/
private static DataSource newPooledDataSource(final Environment env,
final String database) {
BoneCPDataSource datasource = new BoneCPDataSource();
datasource.setJdbcUrl(database);
datasource.setDriverClass(env.getProperty(DB_DRIVER,
DB_DEFAULT_DRIVER));
datasource.setUsername(env.getRequiredProperty(DB_USER));
datasource.setPassword(env.getRequiredProperty(DB_PASSWORD));
datasource.setIdleConnectionTestPeriod(env.getProperty(
DB_IDDLE_CONNECTION_TEST_PERIOD, Integer.class,
DB_DEFAULT_IDDLE_CONNECTION_TEST_PERIOD), TimeUnit.SECONDS);
datasource.setIdleMaxAge(env.getProperty(DB_IDDLE_MAX_AGE,
Integer.class, DB_DEFAULT_IDDLE_MAX_AGE), TimeUnit.SECONDS);
datasource.setMaxConnectionsPerPartition(env.getProperty(
DB_MAX_CONNECTIONS_PER_PARTITION, Integer.class,
DB_DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
datasource.setMinConnectionsPerPartition(env.getProperty(
DB_MIN_CONNECTIONS_PER_PARTITION, Integer.class,
DB_DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
datasource.setPartitionCount(env.getProperty(DB_PARTITION_COUNT,
Integer.class, DB_DEFAULT_PARTITION_COUNT));
datasource.setAcquireIncrement(env.getProperty(DB_ACQUIRE_INCREMENT,
Integer.class, DB_DEFAULT_ACQUIRE_INCREMENT));
datasource.setStatementsCacheSize(env.getProperty(
DB_STATEMENTS_CACHE_SIZE, Integer.class,
DB_DEFAULT_STATEMENTS_CACHE_SIZE));
logger.info("Creating high performance connection pool: '{}'", database);
return datasource;
}