你好,欢迎访问我的博客!登录
当前位置:首页 - MySQL - 正文 求知成瘾,却无作品!

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from

2016-04-25MySQL攻城狮25034°c
A+ A-

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 152,219,305 milliseconds ago.

数据库服务器:mysql5.1

应用服务器:tomcat5.5

出现问题:

   新的应用发布后发现每过一段时间后tomcat就会报错。错误信息大概如下:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 152,219,305 milliseconds ago.  The last packet sent successfully to the server was 152,219,305 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 'autoRecon\=true' to avoid this problem.
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
No operations allowed after connection closed.
java.sql.SQLException: Operation not allowed after ResultSet closed
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
 at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:803)
 at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:6985)
 at com.dz.servlet.LoginServlet.service(LoginServlet.java:54)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:845)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:688)
 at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1315)
 at java.lang.Thread.run(Unknown Source)

在百度里搜到很多,但是都没有解决我的问题,今天看到了一篇写的还算靠谱的文章,http://blog.csdn.net/liuqiyu/article/details/6092377他说的确实没错,但是最关键的地方他说的有点模糊,就是在什么地方修改配置文件,害的我琢磨了好久,我看他也是看别人的方法,而且我估计理解稍微有点错误,修改的位置应该是

[client]
port=3306
[mysql]
default-character-set=gbk

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
wait_timeout=1814400
# The TCP/IP Port the MySQL Server will listen on
port=3306

上面是我贴出来的数据库my.ini配置文件的部分,把wait_timeout=1814400 写在这个位置就没有问题了!!



未定义标签

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。


  登录