一个小项目发现经过一段时间就会出现满屏英文,后买才发现是由于Mysql服务器默认的“wait_timeout”是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。
wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约24.85天
我采用的方法就是将这个八小时修改为24.5天。
在NAVICAT中通过show global variables like 'wait_timeout'; 可以查看当天的值是多少;
通过这个命令可以进行修改set global wait_timeout=2147483;
MySQLorg.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException:
JDBC begin transaction failed: at org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin