这就是我使用 DBCP 1.4 连接工厂创建数据源的方式:
PoolableConnectionFactory factory = new PoolableConnectionFactory(
new DriverManagerConnectionFactory("jdbc:h2:mem:db", "", ""),
new GenericObjectPool(null),
null,
"SELECT 1",
false,
true
);
DataSource src = new PoolingDataSource(factory.getPool());
工作正常,但我不知道如何配置它,这里列出的参数:http: //commons.apache.org/dbcp/configuration.html。例如,我需要设置testWhileIdle
为true
.