标签:
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒
SHOW VARIABLES WHERE VAriable_name = ‘interactive_timeout‘;
-- 会出现wait_timeout与该参数意思相近,修改时,一起修改
SHOW VARIABLES WHERE VAriable_name = ‘%timeout‘;
-- 解决问题
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: org.hibernate.TransactionException: JDBC commit failed
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:130)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:657)
... 29 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during commit(). Transaction resolution unknown.
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
-- 注意点
(1) 碰到这样的问题,先确定是否事务的开启后空闲时间太长导致事务的链接被回收掉了,只要你对数据库进行操作,就不算闲置,不会出现这个问题
(2) 网络出现问题,导致数据库无法链接
(3)
-- linux 系统查询文件中字符串所在文件行数
grep -A 10 -B 5 "查询数据字符串" catalina.out.2015-10-14.log |more
grep -rn "查询字符串" 文件名称
-- p表示行,不能省去
sed -n ‘起始行, 结束行p‘ catalina.out.2015-10-14.log
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
标签:
原文地址:http://www.cnblogs.com/rainy-shurun/p/4886174.html