if (testQuery != null) {
testWhileIdle = true;
}
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUsername(getUser());
dataSource.setPassword(getPassword());
dataSource.setDriverClassName(getDriver());
dataSource.setUrl(getURL());
dataSource.setDefaultAutoCommit(false);
dataSource.setPoolPreparedStatements(true);
// configure pooling
dataSource.setMaxActive(getMaxActive());
dataSource.setMaxIdle(getMaxIdle());
dataSource.setMaxWait(60 * 1000);
// force the pool to timeout to avoid deadlocks
dataSource.setValidationQuery(testQuery);
dataSource.setTestOnBorrow(getTestBeforeUse());
dataSource.setTimeBetweenEvictionRunsMillis(evictionIntervalMS);
dataSource.setMinEvictableIdleTimeMillis(minIdleTimeMS);
dataSource.setTestWhileIdle(testWhileIdle);
_dataSource = dataSource;
}