如何检测连接池中的已关闭连接?

时间:2021-07-24 20:51:01

Imagine having an active BoneCP jdbc connection pool when the network connectivity goes down, then comes back after a minute. In order to automatically reconnect and recreate the pool, how should BoneCP be configured? Currently if I try this, all jdbc connections remain available in the pool and each time my code tries to use them, I get exceptions: "java.sql.SQLException: JZ0C0: Connection is already closed."

想象一下,当网络连接断开时,有一个活动的BoneCP jdbc连接池,然后在一分钟后回来。为了自动重新连接并重新创建池,BoneCP应该如何配置?目前,如果我尝试这个,所有jdbc连接在池中仍然可用,每次我的代码尝试使用它们时,我都会遇到异常:“java.sql.SQLException:JZ0C0:Connection已经关闭。”

Update: Looks like BoneCP may not support this. Does anyone know if (and how) other connection pooling frameworks resolve this problem?

更新:看起来BoneCP可能不支持此功能。有谁知道其他连接池框架是否(以及如何)解决了这个问题?

1 个解决方案

#1


0  

If network goes down, driver should throw an exception which is then caught by BoneCP and destroys all existing connections.

如果网络出现故障,驱动程序应抛出异常,然后由BoneCP捕获并销毁所有现有连接。

#1


0  

If network goes down, driver should throw an exception which is then caught by BoneCP and destroys all existing connections.

如果网络出现故障,驱动程序应抛出异常,然后由BoneCP捕获并销毁所有现有连接。