最新关于MySQL的wait_timeout连接超时问题报错解决方案

上传人:夏** 文档编号:478103034 上传时间:2023-06-06 格式:DOC 页数:6 大小:35.50KB
返回 下载 相关 举报
最新关于MySQL的wait_timeout连接超时问题报错解决方案_第1页
第1页 / 共6页
最新关于MySQL的wait_timeout连接超时问题报错解决方案_第2页
第2页 / 共6页
最新关于MySQL的wait_timeout连接超时问题报错解决方案_第3页
第3页 / 共6页
最新关于MySQL的wait_timeout连接超时问题报错解决方案_第4页
第4页 / 共6页
最新关于MySQL的wait_timeout连接超时问题报错解决方案_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《最新关于MySQL的wait_timeout连接超时问题报错解决方案》由会员分享,可在线阅读,更多相关《最新关于MySQL的wait_timeout连接超时问题报错解决方案(6页珍藏版)》请在金锄头文库上搜索。

1、最新关于MySQL的wait_timeout连接超时问题报错解决方案关于MySQL的wait_timeout连接超时问题报错解决方案Mysql效劳器默认的“wait_timeout是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约24.85天所以即使你MySQL通过my.ini 在# The TCP/IP Port the MySQL Server will l

2、isten onport=3306下面添加# this is myown dinifition for mysql connection timeoutwait_timeout=31536000interactive_timeout=31536000无论超过最大限度多大的数值,只能被MySQL解析为2147483,2147483天后你的程序该出什么错还是什么错,防止不了的在说这个错误之前先说明我的工程是通过Hibernate来进行数据库操作的关于MySQL连接超时问题,估计很多人都遇到过:大致情形都是这样,开发测试时程序都是正常的,一到第二天就出先莫名错误,比方在我的工程中就是定时任务执行,每

3、天凌晨一点执行一次,也就是24小时每隔24小时执行,远远超出了8小时如果你刚好在数据库超时的第一时间内看到日志记录的话那么,第一次超时发生的错误就是这样的:ERROR org.hibernate.util.JDBCExceptionReporter - Communications link failureLast packet sent to the server was 0 ms ago.如果不是第一次超时后执行,以后每次报错就变成嵌套的错误了,就是下面这样:ERROR org.hibernate.util.JDBCExceptionReporter -No operations allo

4、wed after connection closed.Connection was implicitly closed due to underlying exception/error:* BEGIN NESTED EXCEPTION * MESSAGE: The last packet successfully received from the server was86395 milliseconds ago.The last packet sent successfully to the server was 86395 milliseconds ago, which is long

5、er 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 probl

6、em.STACKTRACE:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was86395 milliseconds ago.The last packet sent successfully to the server was 86395 milliseconds ago, which is longer than the server configured value of wait_timeout. You sho

7、uld 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

8、(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)at java.lang.reflect.Constructor.newInstance(Unknown Source)at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)at com.mysql.jdbc.SQLE

9、rror.createCommunicationsException(SQLError.java:1074)at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3270)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1932)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)at com.mysql.jdb

10、c.PreparedStatement.executeInternal(PreparedStatement.java:1761)at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1912)at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)at org.hibernate.loade

11、r.Loader.doQuery(Loader.java:697)at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)at org.hibernate.loader.Loader.doList(Loader.java:2232)at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)at org.hibernate.loader.Loader.list(Loader.java:2124)at o

12、rg.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)at org.hibernate.impl

13、.QueryImpl.list(QueryImpl.java:102)at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)at com .util.db.TargetRecordDaoImpl.findbyIdAndDate(TargetRecordDaoImpl.java:23)at com .util.parser.ExcelOperate.readExcel(ExcelOperate.java:324)at com .util.parser.ExcelParser.parser(E

14、xcelParser.java:41)at com .util.timer.CRMExcelParserTarger.execute(CRMExcelParserTarger.java:76)at org.quartz.core.JobRunShell.run(JobRunShell.java:199)at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)Caused by: .SocketException: Software caused connection abort: socke

15、t write errorat .SocketOutputStream.socketWrite0(Native Method)at .SocketOutputStream.socketWrite(Unknown Source)at .SocketOutputStream.write(Unknown Source)at java.io.BufferedOutputStream.flushBuffer(Unknown Source)at java.io.BufferedOutputStream.flush(Unknown Source)at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3251). 24 more* END NESTED EXCEPTION *具体解释是这样的:Mysql效劳器默认的“wait_timeout是8小时【也就是默认的值默认是28800秒】,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection,通俗的讲就是一个连接在8小时内没有活动,就会自动断开该连接。wait timeout的值可以设定,但最多只能是2147483,不能再大了。也就是约24.85天所以即使你MySQL通过my.ini 在# T

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号