`
kabuchino
  • 浏览: 76055 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

autoReconnect=true设置无效 待解决

阅读更多

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 145,178,488 milliseconds ago. The last packet sent successfully to the server was 145,178,488 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

 

数据库:mysql 5.5.8

系统将read,write分两个DB

read,正常

但是在write的时候,报以上错误。而在数据库的配置中,已经有autoReconnect=true 看来不起作用。。。

临时解决方法,就是重启应用。

但是不是解决之道.

 

网上搜索,说是修改mysql数据库的wait_timeout 。但遭到了DBA的强烈抵制,会影响其他的mysql的性能。

 

记录一下问题,待解决。。。

 

备注:mysql5以上的,设置autoReconnect=true 是无效的 只有4.x版本,起作用

分享到:
评论
6 楼 pkkfcuso 2013-07-30  
<beans:property name="timeBetweenEvictionRunsMillis" value="3600000" />
   <beans:property name="testWhileIdle" value="true" />
   <beans:property name="validationQuery" value="select 1 from dual" />

是因为mysql默认wait_timeout为8小时,超过后连接池会自动关闭

连接数据库时修改这三个参数就可以了· 每个小时自动连接一次·保持连接可用
5 楼 pkkfcuso 2013-07-30  
http://www.cnblogs.com/Bruce-Goo/p/3224829.html
4 楼 kabuchino 2013-03-25  
一直没有找出处理的办法

不过后来由于业务的需要,需要做一个每天都要启动的定时器。
自从定时器部署了之后,就再也没有出现这个问题了。
很无奈的解决之道
3 楼 lvye351 2013-02-06  
连接池自己改,取链接前检查,如果无效,则重新获取连接。apache 的dbcp,c3p0连接池都支持此属性。dbcp 参数是TestOnBorrow
2 楼 lvye351 2013-02-05  
楼主你最后怎么解决的?
1 楼 lvye351 2013-02-05  
我也碰到此问题。mysql autoReconnect=true。连接里autoReconnect=true 看来不起作用。


相关推荐

Global site tag (gtag.js) - Google Analytics