com.mysql.jdbc.exceptions.jdbc4.CommunicationsException/com.atomikos.datasource.ResourceException异常解决
tomcat+mysql部署,每天早晨第一次访问web项目,出现mysql的连接timeout异常:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException或com.atomikos.datasource.ResourceException。
############################################################################
com.atomikos.datasource.ResourceException: XA resource 'center': resume for XID '3139322E3136382E312E35332E746D30303030363030303530:3139322E3136382E312E35332E746D37' raised 0: unknown com.mysql.jdbc.jdbc2.optional.MysqlXAException: The last packet successfully received from the server was 50,024,067 milliseconds ago. The last packet sent successfully to the server was 50,024,068 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. ############################################################################
The error occurred while applying a parameter map.
--- Check the ts_user.ibatorgenerated_selectByExample-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received from the server was 232,007,469 milliseconds ago.
The last packet sent successfully to the server was 232,007,485 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.;
nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred while applying a parameter map.
--- Check the ts_user.ibatorgenerated_selectByExample-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received from the server was 232,007,469 milliseconds ago.
The last packet sent successfully to the server was 232,007,485 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.
原因
mysql5连接的等待时间(wait_timeout)默认是8小时。
查看方法
show global variables like 'wait_timeout';
查看结果:
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)
在wait_timeout时间里,mysql的connection处于等待状态,过了这时间mysql5就关闭了,但是java application的连接池仍然有合法的connection,当你再操作数据库时,就会出现这样的问题。
解决方法
mysql5之前的版本,可以在jdbc连接的url中加入:autoReconnect = true
mysql5中wait_timeout在window中最大为24天,在linux中最大为365天。
a、修改配置
如果在window中设置为21天,改mysql5的安装文件夹中的my.ini
如果在linux中/etc/my.cnf,添加一行:wait_timeout = 1814400,重启mysql,添加效果如下:

b、直接用sql命令行修改(重启有还原为28800,不推荐)
mysql> set global wait_timeout=1814400;
mysql> show global variables like 'wait_timeout';
查看mysql版本
select version();
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException/com.atomikos.datasource.ResourceException异常解决的更多相关文章
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决办法
09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.my ...
- mysql 数据库问题com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
本文转自:http://blog.csdn.net/zmzsoftware/article/details/6835604 MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc ...
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
-- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...
- Oozie时出现Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure?
不多说,直接上干货! 问题详情 [hadoop@bigdatamaster oozie--cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -ru ...
- 异常解决:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
异常描述 这个异常通常有如下信息: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failu ...
- Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
很长的报错,截取 ERROR c.a.d.p.DruidDataSource - discard connection com.mysql.jdbc.exceptions.jdbc4.Comm ...
- Caused by: java.net.ConnectException: Connection refused/Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
1.使用sqoop技术将mysql的数据导入到Hive出现的错误如下所示: 第一次使用命令如下所示: [hadoop@slaver1 sqoop--cdh5.3.6]$ bin/sqoop impor ...
- org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent succ
数据库 没有开启 连接失败 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause ...
- mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)
报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications lin ...
随机推荐
- php excel 读取日期问题
在 php excel 读取 xls 格式的文件时,xls 上面显示的是正常的日期格式 但是读取出来的话,就会是一个万位整形数据,这显然不是我们想要的日期 读取出来的结果: 41807 $t = 41 ...
- 《DSP using MATLAB》示例Example 8.14
%% ------------------------------------------------------------------------ %% Output Info about thi ...
- 《DSP using MATLAB 》示例Example6.3
代码: C0 = 0; B1 = [2 4; 3 1]; A1 = [1 1 0.9; 1 0.4 -0.4]; B2 = [0.5 0.7; 1.5 2.5; 0.8 1]; A2 = [1 -1 ...
- [Luogu4715]「英语」Z 语言
luogu description 你有一个长度为\(n\)的串\(A\)和一个长度为\(m\)的串\(B\),字符集大小\(2^{31}\),且同一个串中没有相同的元素. 定义\(B\)串与\(A_ ...
- .NET平台上的Model-View-Presenter模式实践
为什么要写这篇文章 笔者当前正在负责研究所中一个项目,这个项目基于.NET平台,初步拟采用C/S部署体系,所以选择了Windows Forms作为其UI.经过几此迭代,我们发现了一个问题:虽然业务逻辑 ...
- oracle 之 控制oracle RAC 进行并行运算
RAC的一大优点就是可以跨节点进行并行计算,那么如何控制并行运算?这就是这篇文章要讨论的内容. 10 g 中: 合理设置跨节点并行,需要先设置一些参数:instance_groups:这个参数主要是设 ...
- JavaSE 手写 Web 服务器(一)
原文地址:JavaSE 手写 Web 服务器(一) 博客地址:http://www.extlight.com 一.背景 某日,在 Java 技术群中看到网友讨论 tomcat 容器相关内容,然后想到自 ...
- Oracle分组函数实例
分组函数也叫聚合函数.如果在查询只想要查分组函数,那么跟平时的查询语句并无不同: SQL ,,,,) ; SUM(T.PRIZENUM) AVG(T.PRIZENUM) --------------- ...
- IIS注册Framework4.0
打开iis,确认一下framework4.0是否已经安装. 开始->控制面板->管理工具->Internet信息服务->应用程序池(左边栏)->观察右边主界面.net f ...
- 系统管理员都要知道的 30 个 Linux 系统监控工具
1. top - 进程活动监控命令 top 命令会显示 Linux 的进程.它提供了一个运行中系统的实时动态视图,即实际的进程活动.默认情况下,它显示在服务器上运行的 CPU 占用率最高的任务,并且每 ...