Mysql的wait_timeout

问题: mysql

ssh+mysql项目,数据源为dbcp,隔夜后访问会出现下列错误
sql

Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed:
...

缘由: shell

mysql存在一项属性“wait_timeout”,默认值为28800秒(8小时),
经过下面口令能够查看 ssh

mysql> show global variables like 'wait_timeout';
其意思为mysql的一个connection空闲时间超过8小时,mysql会自动断开该链接。
因为dbcp没有检验该connection是否有效,因此用其进行数据操做便会出现异常。


解决方法: hibernate

修改dbcp配置: code

timeBetweenEvictionRunsMillis = 20000  
minEvictableIdleTimeMillis = 28700
“timeBetweenEvictionRunsMillis ”  dbcp每2000秒进行一次connection的检验, “minEvictableIdleTimeMillis ” 每次检验中将超过28700秒处于空闲的connection断开
相关文章
相关标签/搜索