zoukankan      html  css  js  c++  java
  • The last packet successfully received from the server was 2,926,157 milliseconds ago. The last packet sent successfully to the server was 2,926,158 milliseconds ago. is longer than the server configured value of 'wait_timeout'. 解决办法

    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 2,926,157 milliseconds ago. The last packet sent successfully to the server was 2,926,158 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.

    解决办法:
    如果连接闲置8小时 (8小时内没有进行数据库操作), mysql就会自动断开连接, 要重启tomcat.
    不用hibernate的话, connection url加参数: autoReconnect=true
    用hibernate的话, 加如下属性:

    <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider
            </property>
            <property name="hibernate.c3p0.max_size">50</property>
            <property name="hibernate.c3p0.min_size">5</property>
            <property name="hibernate.c3p0.timeout">10</property>
            <property name="hibernate.c3p0.max_statements">50</property>
            <property name="hibernate.c3p0.idle_test_period">10</property>
            <property name="hibernate.c3p0.acquire_increment">2</property>

  • 相关阅读:
    Javaweb 第4 天xml 课程
    Javaweb 第2天 JavaScript课程
    Javaweb 第1天 HTML和CSS课程
    第27天反射(解剖)技术
    Ip 讲解
    第26 天网络编程
    第25天多线程、网络编程
    【剑指offer】连续子数组的最大和,C++实现
    [剑指offer]数组中最小的K个数,C++实现
    【剑指offer】数组中出现次数超过数组长度一半的数字,C++实现
  • 原文地址:https://www.cnblogs.com/NeilLing/p/4378360.html
Copyright © 2011-2022 走看看