成功发送到服务器的最后一个数据包> 70,400,003毫秒前。比配置的服务器长 [英] The last packet sent successfully to the server was > 70,400,003 milliseconds ago. is longer than the server configured

查看:100
本文介绍了成功发送到服务器的最后一个数据包> 70,400,003毫秒前。比配置的服务器长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的异常:


javax.persistence.PersistenceException:异常[EclipseLink-4002]
(Eclipse持久性服务 - 2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.DatabaseException内部
异常:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
成功接收的最后一个数据包从服务器是70,400,002
毫秒前。成功发送到服务器的最后一个数据包是70,400,003毫秒前的
。比服务器配置的
值'wait_timeout'更长。在应用程序中使用之前,应考虑使用过期和/或
测试连接有效性,为客户端超时增加
服务器配置的值,或者使用
Connector / J连接属性'autoReconnect = true ',以避免
问题。

我做了一些研究,并将persistance.xml更改为此



最新

 <?xml version =1.0编码= UTF-8 >?; 
< persistence version =2.1xmlns =http://xmlns.jcp.org/xml/ns/persistencexmlns:xsi =http://www.w3.org/2001/XMLSchema-实例xsi:schemaLocation =http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd\">
< persistence-unit name =unicorntransaction-type =RESOURCE_LOCAL>
< provider> org.hibernate.ejb.HibernatePersistence< / provider>
< class> com.rh.xxx< / class>
<属性>
< property name =hibernate.connection.driver_classvalue =com.mysql.jdbc.Driver/>
< property name =hibernate.dialectvalue =org.hibernate.dialect.MySQLDialect/>
< property name =hibernate.connection.urlvalue =jdbc:mysql:// xxx:3306 / unicorndb?zeroDateTimeBehavior = convertToNull/>
< property name =hibernate.connection.passwordvalue =xxx/>
< property name =hibernate.connection.usernamevalue =student/>
< property name =hibernate.c3p0.max_sizevalue =100/> <! - JDBC连接的最大数量 - >
< property name =hibernate.c3p0.min_sizevalue =10/> <! - JDBC连接的最小数量 - >
< property name =hibernate.c3p0.idle_test_periodvalue =500/>
< property name =hibernate.c3p0.acquire_incrementvalue =1/>
< / properties>
< / persistence-unit>
< /余辉>

最新的代码看起来是否正确?

任何帮助将不胜感激

解决方案

首先,保持简单的测试,只需使用

 < property name =hibernate.c3p0.testConnectionOnCheckoutvalue =true/> 

而不是空闲的连接检查。请参阅连接测试上的c3p0文档

如果问题仍然存在,那么问题不太可能是池所持有的连接,而是应用程序正在检出并持续打开一段时间的一些连接或连接。理想情况下,连接应该被检出,使用,然后立即签入(并且使用试用资源或小心最后块)。


I have below exception

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 70,400,002 milliseconds ago. The last packet sent successfully to the server was 70,400,003 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.

I did some research and change persistance.xml to this

Latest

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="unicorn" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.rh.xxx</class>
    <properties>
      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.connection.url" value="jdbc:mysql://xxx:3306/unicorndb?zeroDateTimeBehavior=convertToNull"/>
      <property name="hibernate.connection.password" value="xxx"/>
      <property name="hibernate.connection.username" value="student"/>
      <property name="hibernate.c3p0.max_size" value="100" />  <!--max number of JDBC connections -->
      <property name="hibernate.c3p0.min_size" value="10" />   <!--minimum number of JDBC connections-->
      <property name="hibernate.c3p0.idle_test_period" value="500" />
      <property name="hibernate.c3p0.acquire_increment" value="1" />
    </properties>
  </persistence-unit>
</persistence>

Did the latest code looked correct?

Any help would be appreciated

解决方案

To start, keep your testing simple, just use

<property name="hibernate.c3p0.testConnectionOnCheckout" value="true" />

instead of the idle Connection check. See c3p0 docs on Connection testing

If the problem, um, persists then the issue isn't likely to be Connections held by the pool, but some Connection or Connections that your application is checking out and holding open for an indefinite period. Ideally, Connections should be checked out, used, then checked in immediately (and robustly, using try-with-resources or a careful finally block).

这篇关于成功发送到服务器的最后一个数据包&gt; 70,400,003毫秒前。比配置的服务器长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆