PostgreSQL的HikariCP:尚未实现setQueryTimeout(int) [英] HikariCP with PostgreSQL: setQueryTimeout(int) is not yet implemented
本文介绍了PostgreSQL的HikariCP:尚未实现setQueryTimeout(int)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在PostgreSQL上使用HikariCP,但是它不起作用。它会引发异常:
I tried to use HikariCP with PostgreSQL but it doesn't work. It throws an exception:
WARN [2014-10-24 14:38:54,195] com.zaxxer.hikari.pool.HikariPool: Exception during keep alive check, that means the connection must be dead.
! org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Statement.setQueryTimeout(int) is not yet implemented.
! at org.postgresql.Driver.notImplemented(Driver.java:753) ~[postgresql-9.0-801.jdbc4.jar:na]
! at org.postgresql.jdbc2.AbstractJdbc2Statement.setQueryTimeout(AbstractJdbc2Statement.java:656) ~[postgresql-9.0-801.jdbc4.jar:na]
! at com.zaxxer.hikari.pool.HikariPool.isConnectionAlive(HikariPool.java:473) [HikariCP-java6-2.1.0.jar:na]
! at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:178) [HikariCP-java6-2.1.0.jar:na]
! at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:94) [HikariCP-java6-2.1.0.jar:na]
我尝试了所有可能的驱动程序版本(包括 org.postgresql:postgresql:9.3-1102-jdbc41
)-没有任何帮助。有人在PostgreSQL中使用它吗?
I tried all possible driver versions (including org.postgresql:postgresql:9.3-1102-jdbc41
) - nothing helped. Did anybody use it with PostgreSQL?
这是我的配置文件:
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="connectionTestQuery" value="SELECT 1" />
<property name="dataSourceClassName" value="org.postgresql.ds.PGSimpleDataSource" />
<property name="maximumPoolSize" value="${jdbc.maximumPoolSize:20}" />
<property name="idleTimeout" value="${jdbc.idleTimeout:600000}" />
<property name="dataSourceProperties">
<props>
<prop key="databaseName">vidsearch_test</prop>
<prop key="user">${hibernate.connection.username}</prop>
<prop key="password">${hibernate.connection.password}</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig"/>
</bean>
推荐答案
不要使用 connectionTestQuery
。允许HikariCP使用 Connection.isValid()
方法遵循其默认行为。这需要一个JDBC4驱动程序。
Don't use a connectionTestQuery
. Allow HikariCP to follow its default behavior of using the Connection.isValid()
method. This requires a JDBC4 driver.
这篇关于PostgreSQL的HikariCP:尚未实现setQueryTimeout(int)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文