zoukankan      html  css  js  c++  java
  • 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 'autoReconnect=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 写在这个位置就没有问题了!!

    =================================

    PS:

      1、这篇文章是从我自己网易博客上搬过来的,感觉写的太零碎了,以后就都在博客园写了,别的地方就不写了。

  • 相关阅读:
    由少林寺比武想到软件行业分工
    微软SQL 报表服务的研究
    图形化窗体表单设计器
    多层数据源处理复杂数据结构
    Universal menu command handle pattern
    使用foreach来读取记录
    C#计算20902个汉字的拼音首字母
    软件的价值
    虚控件在GUI编程中的应用
    深刻的检讨书
  • 原文地址:https://www.cnblogs.com/ssh2/p/3484992.html
Copyright © 2011-2022 走看看