我尝试使用 BoneCP 来汇集 Vertica 连接,但遇到了错误
[BoneCP-pool-watch-thread-vertica pool] ERROR com.jolbox.bonecp.PoolWatchThread - Error in trying to obtain a connection. Retrying in 7000ms
java.sql.SQLException: [Vertica][JDBC](11760) Cannot call setReadOnly while Connection is in a transaction.
at com.jolbox.bonecp.ConnectionHandle.setReadOnly(ConnectionHandle.java:1279)
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:254)
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:185)
at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:114)
at com.jolbox.bonecp.PoolWatchThread.run(PoolWatchThread.java:81)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
这是我正在使用的代码
BoneCPConfig bvcp = new BoneCPConfig();
Class.forName("com.vertica.jdbc.Driver");
bvcp.setPoolName("vertica pool");
bvcp.setDefaultReadOnly(false);
bvcp.setJdbcUrl("jdbc:vertica://vertica-server:5433/schema");
bvcp.setUser("username");
bvcp.setPassword("vertica-pwd");
BoneCPDataSource bds = new BoneCPDataSource(bvcp);
JdbcTemplate template = new JdbcTemplate(ds);
List<Map<String, Object>> ret = template
.queryForList("select * from table1 ");
我用 Oracle 和 HSQL 尝试了相同的代码,它工作正常。
这是使用 Vertica JDBC 驱动程序 5.1.1 和 BoneCP 0.8.0-rc1
任何帮助是极大的赞赏。