mysql 数据库连接超时的问题 autoReconnect=true
最近在使用spring-jdbc数据库连接管理时,出现一个奇怪问题,当天部署运行没问题,第二天再试就报以下异常问题
org.springframework.dao.RecoverableDataAccessException: PreparedStatementCallback; SQL []; The last packet successfully received from the server was 56,799,849 milliseconds ago. The last packet sent successfully to the server was 56,799,850 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.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 56,799,849 milliseconds ago. The last packet sent successfully to the server was 56,799,850 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. at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:99) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:849) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at com.pyw.email.provider.dao.EmailDao.insert(EmailDao.java:39) ~[email-provider-1.1.0.jar:na]
at com.pyw.email.provider.thread.EmailSendThread.run(EmailSendThread.java:63) ~[email-provider-1.1.0.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_79]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 56,799,849 milliseconds ago. The last packet sent successfully to the server was 56,799,850 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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_79]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_79]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_79]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_79]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3743) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2506) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2677) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5098) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994) ~[mysql-connector-java-5.1.40.jar:5.1.40]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[commons-dbcp-1.4.jar:1.4]
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[commons-dbcp-1.4.jar:1.4]
at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:851) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate$3.doInPreparedStatement(JdbcTemplate.java:849) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589) ~[spring-jdbc-3.2.9.RELEASE.jar:3.2.9.RELEASE]
... 6 common frames omitted
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.7.0_79]
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:1.7.0_79]
at java.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[na:1.7.0_79]
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[na:1.7.0_79]
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) ~[na:1.7.0_79]
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3725) ~[mysql-connector-java-5.1.40.jar:5.1.40]
... 19 common frames omitted
解决方法参考文献:
http://blog.csdn.net/bluesnail216/article/details/15810119
http://www.cnblogs.com/mumuxinfei/p/5100757.html
mysql 数据库连接超时的问题 autoReconnect=true的更多相关文章
- mysql5 数据库连接丢失问题,autoReconnect=true不起作用
The last packet successfully received from the server was 55,404,563 millise 方案1 定时器 方案2 修改连接池容量 mys ...
- 数据库连接超时:“The last packet successfully received from the server was xxx milliseconds ago”
产生的原因:应用方的数据库连接有效期时间,大于数据库自己设置的有效期. 解决方案: 一.修改druid配置(如果使用druid的话) spring.datasource.druid.validatio ...
- 连接数据库超时设置autoReconnect=true
1,问题现象: com.mysql.jdbc.CommunicationsException: The last packet successfully received from the serve ...
- MySQL 参数autoReconnect=true 解决8小时连接失效
<!-- dataSource加参数 处理mysql 8小时自动断开连接的问题 --> <property name="testWhileIdle" va ...
- Hibernate连接数据库超时设置autoReconnect=true
如果连接闲置8小时 (8小时内没有进行数据库操作), mysql就会自动断开连接, 要重启tomcat. 不用hibernate的话, connection url加参数: autoReconnect ...
- MySQL 参数autoReconnect=true 解决8小时连接失效(转)
即使在创建Mysql时url中加入了autoReconnect=true参数,一但这个连接两次访问数据库的时间超出了服务器端wait_timeout的时间限制,还是会CommunicationsExc ...
- mysql数据库连接出问题,提示超时 java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.解决办法
mysql数据库连接出问题,提示超时,后来发现问题在于连接mysql数据库的jar包跟数据库版本不对应导致的,更换jar包一致就解决了.
- mysql连接超时
这几天在跟踪一个项目的时候,老是发现mysql连接报timeout的异常. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException ...
- 查找Mysql数据库连接jar包和对应的Driver和Url
以前写jdbc连接向来都是直接copy,对于连接数据库的jar包在哪下载,对应的Driver类是哪一个,数据库连接串怎么找等等都没有做过,今天从零开始整了一遍. 使用的数据库是Mysql 一.已安装了 ...
随机推荐
- phpunit 测试框架安装
PHPUnit是一个轻量级的PHP测试框架.它是在PHP5下面对JUnit3系列版本的完整移植,是xUnit测试框架家族的一员(它们都基于模式先锋Kent Beck的设计).来自百度百科 一.下载wg ...
- Linux的3个文件时间
文件的三个时间相信大家都已经很熟悉windows操作系统了,当我们在windows系统下创建一个文件时,系统同时会为这个文件建立相关的参数去描述这个文件,如图: 这些参数包括文件的大小,文件类型,位置 ...
- Ubuntu学习总结-10 XManager
最近接触到一个很有意思的实验,在这里与大家分享,实验目标在Window显示UBuntu程序. 1 测试环境: Windows8的IP地址 : 192.168.7.126 UBuntu16的IP地址 : ...
- A couple of notes about .NET Framework 4.6 setup behaviors
https://blogs.msdn.microsoft.com/astebner/2015/06/17/a-couple-of-notes-about-net-framework-4-6-setup ...
- Genymotion模拟器连接Eclipse的总结[转]
Genymotion模拟器连接Eclipse的总结 按官网上说明安装并配置好Genymotion ,再安装好对应的Eclipse Plugin(http://plugins.genymotion.co ...
- 【原】聊一聊 url 编码问题
最近项目中遇到需要编码的一个问题,在encode和encodeURIComponent上绕了个小圈,所以打算总结一下js的编码问题,网上也有很多类似的文章,不过呢,总结出来的东西才是自己滴 为什么需要 ...
- UML大战需求分析--阅读笔记3
这次阅读的是第四章,流程分析利器之 – 活动图.对需求有两种分析的方式:结构建模与行为建模.活动图是行为建模中经常使用的一种图.由流程图发展而来. 活动图中有一些名词:开始状态.结束状态.活动.判断. ...
- the import android cannot be resolved
1.先更新SDK 2.从Window选择SDK并且Apply 3.从Project选择Android的版本
- App Extension访问Cocoapods引入的第三方库
步骤一: PROJECT --info --configurations,将对应的Debug和Release 设置成pods.debug和pods.release 步骤2:编译一下(本人遇到的问 ...
- 常见ES5方法
• ES5 JSON扩展JSON.parseJSON.stringify • ES5 Object扩展Object.createObject.keys • Date对象Date.now • ES5 F ...