我正在尝试这个:
final PoolableConnectionFactory factory = new PoolableConnectionFactory(
new DriverManagerConnectionFactory("jdbc:hsqldb:mem:testdb", "sa", ""),
new GenericObjectPool(null),
null,
"SELECT 1 from INFORMATION_SCHEMA.SYSTEM_USERS",
true,
false,
Connection.TRANSACTION_NONE
);
DataSource ds = new PoolingDataSource(factory.getPool());
ds.getConnection();
无济于事,抛出异常:
java.util.NoSuchElementException: Could not create a validated object, cause: Invalid argument in JDBC call
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1191)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
怎么了?
答案 0 :(得分:1)
尝试像这样设置PoolableConnectionFactory
PoolableConnectionFactory factory = new PoolableConnectionFactory(
new DriverManagerConnectionFactory("jdbc:hsqldb:mem:testdb", "sa", ""),
new GenericObjectPool(null),
null, null, false, true);
检查它是否有效。然后检查与事务相关的额外参数是否在DBCP版本中有效。