如果连接无效,BoneCP将不会返回或抛出

时间:2013-05-31 13:45:43

标签: java bonecp

使用BoneCp 0.7.1

我设置了我的应用程序,一切正常,但随后数据库脱机。

在下一个应用程序请求getConnection()开始抛出内部异常并启动重试机制但getConnection()从未返回,导致线程挂起。

以下异常会反复抛出,但您希望getConnection()返回NULL或至少抛出SQLException,以便您可以处理它。

这看起来很相似:http://jolbox.com/forum/viewtopic.php?t=339&p=1390但是我的问题在建立连接后出现了。

还看到了...... BoneCP doesn't recover from broken connection 我会尝试8.0-rc1

10:03:58.302 [BoneCP-pool-watch-thread-com.xxx.xxxjdbc-28eb0780-683c-4fa8-92dc-57b2d071af2a] ERROR com.jolbox.bonecp.ConnectionHandle - Database access problem.
Killing off all remaining connections in the connection pool. SQL State = 08S01
10:03:58.318 [BoneCP-pool-watch-thread-com.xxx.xxxjdbc-28eb0780-683c-4fa8-92dc-57b2d071af2a] ERROR com.jolbox.bonecp.PoolWatchThread - Error in trying to obtain
a connection. Retrying in 500ms
java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:434) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:183) ~[jtds-1.3.0.jar:1.3.0]
at java.sql.DriverManager.getConnection(DriverManager.java:579) ~[na:1.7.0_17]
at java.sql.DriverManager.getConnection(DriverManager.java:221) ~[na:1.7.0_17]
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) ~[bonecp-0.7.1.RELEASE.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.ConnectionHandle.obtainInternalConnection(ConnectionHandle.java:211) ~[bonecp-0.7.1.RELEASE.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:170) ~[bonecp-0.7.1.RELEASE.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:101) [bonecp-0.7.1.RELEASE.jar:0.7.1.RELEASE]
at com.jolbox.bonecp.PoolWatchThread.run(PoolWatchThread.java:82) [bonecp-0.7.1.RELEASE.jar:0.7.1.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_17]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_17]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) ~[na:1.7.0_17]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) ~[na:1.7.0_17]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) ~[na:1.7.0_17]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) ~[na:1.7.0_17]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) ~[na:1.7.0_17]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) ~[na:1.7.0_17]
at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_17]
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_17]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_17]
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:300) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:253) ~[jtds-1.3.0.jar:1.3.0]
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:329) ~[jtds-1.3.0.jar:1.3.0]
... 11 common frames omitted

尝试8.0-rc2同样的问题getConnection()不会返回。

1 个答案:

答案 0 :(得分:0)

旧问题,但我建议您尝试HikariCP以提高可恢复性。