网站地图    收藏   

主页 > 后端 > mysql数据库 >

The last packet successfully received from the server was525

来源:自学PHP网    时间:2014-09-27 10:14 作者: 阅读:

[导读] The last packet successfully received from the server was52536 seconds ago.The last packet sent successfully to the server was 52536 seconds ago, which is longer than the server configured value of wait_timeout . You should consider either e...

The last packet successfully received from the server was52536 seconds ago.The last packet sent successfully to the server was 52536 seconds ago, which  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.  

        问:怎样才能解决mysql 8小时空闲后连接超时的问题?

  答:当应用程序和数据库建立连接时,如果超过了8个小时,应用程序句不会去访问数据库,数据库就会出现断掉连接的现象 。这时再次访问就会抛出异常,异常如下:

Communications link failure due to
underlying exception:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
STACKTRACE:
java.io.EOFException
  at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1913)
  at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2304)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2803)
  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
...

 

  一般的解决方法大多是在数据库连接字符串中增加“autoReconnect=true ”选项。但是这只对mysql4以前的版本有效。在最新的mysql中是无效的。其实要解决这个问题也有一个简单的方法,就是修改mysql的启动参数。缺省情况下mysql的timeout时间是28800秒,正好是8小时,增加一个0就可以了。

  同理也可以在" my.ini"文件中增加此参数。

mysqld-nt --default-table-type=innodb --interactive_timeout=288000

 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论