MYSQL 8小时超时问题 [英] MYSQL 8 Hours Time out Problem
问题描述
我正在使用MYSQL 5.0和Tomcat 5.5. 8小时后,默认情况下,MYSQL关闭,并关闭所有空闲连接,因此我遇到了SQL异常.此问题的任何解决方案
I am using MYSQL 5.0 and Tomcat 5.5. After 8 hours , MYSQL closes by default closes all idle connections and so I am getting an SQL Exception .Any solution to this problem
推荐答案
您正在使用哪个连接池?大多数允许定期执行心跳命令,以防止连接空闲.
Which connection pool are you using? Most allow a heartbeat command to be executed periodically to keep connections from idling out.
查看 DBCP配置页面,我认为您应该设置一个适当的(便宜)validationQuery
.然后,您可以告诉DBCP在可能退出空闲连接(testWhileIdle
)时进行测试,也可以告诉DBCP在返回连接之前进行测试(testOnBorrow
).第一个会(希望如此!)使您的空闲连接保持活动状态;第二个不会,但是不会返回断开的连接(即,如果需要的话可以创建一个新的连接).
Looking at the DBCP configuration page, I think you should set an appropriate (cheap) validationQuery
. You could then either tell DBCP to test this when potentially evicting idle connections (testWhileIdle
) or tell it to test just before returning the connection (testOnBorrow
). The first would (hopefully!) keep your idle connections alive; the second wouldn't, but wouldn't return you broken connections (i.e. if would create a new one if necessary).
这篇关于MYSQL 8小时超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!