数据库连接长时间空闲后,爆连接已经关闭的解决方法

在很多场合都碰到有人提问: 第二天第一次访问应用,总是报连接已经关闭(Connection Close)

其实,数据库连接池大都已经考虑了这个问题,进行设置一下即可

Apache DBCP

dataSource.setValidationQuery('select 1');

C3po:

dataSource.setTestConnectionOnCheckout(true);dataSource.setPreferredTestQuery('select 1')

Proxool:

dataSource.setTestBeforeUse(true);dataSource.setHouseKeepingTestSql('select 1')
posted @ 2013-03-22 14:14  cncoffee  阅读(702)  评论(0编辑  收藏  举报