JDBC连接池未在Tomcat中重新打开连接 [英] JDBC Connection pool not reopening connections in Tomcat

查看:133
本文介绍了JDBC连接池未在Tomcat中重新打开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Tomcat设置为使用连接池,但是在连接上的MySQL超时后,先前在该池中打开的连接未打开.这是我的context.xml文件的样子:

I have set up Tomcat to use a connection pool yet after the MySQL timeout on connections the connections previously open in the pool are not opened. Here is what my context.xml file looks like:

<Resource name="jdbc/hpsgDB" auth="Container" type="javax.sql.DataSource"
           maxActive="5" maxIdle="3" maxWait="10000"
           username="uname" password="password" driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://localhost:3306/hpsgdb?autoReconnect=true"/>

如您所见,我将autoReconnect包含为true,但没有包含.我已经在8小时后检查了数据库上的进程,这是设置为超时的时间.

As you can see I have included autoReconnect as true yet it doesn't. I have checked the process on the database after 8 hours which is what the time out is set to.

推荐答案

尝试添加验证查询属性.这样应该具有在超时后自动关闭并重新打开连接的效果:

Try adding a validation query attribute. This should have the effect of automatically closing and re-opening the connection after a timeout like this:

validationQuery="SELECT 1"

这篇关于JDBC连接池未在Tomcat中重新打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆