简体   繁体   English

使用c3p0和Hibernate的管道中断异常是什么

[英]What does the Broken pipe exception using c3p0 and Hibernate

例外是:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was45569 milliseconds ago.The last packet sent successfully to the server was 45569 milliseconds 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.

What probably happens is that the connection in the C3P0 pool is closed by MySQL because it's kept open for longer that the interactive_timeout ( http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_interactive_timeout ) 可能发生的情况是MySQL关闭了C3P0池中的连接,因为它保持打开状态的时间超过了Interactive_timeout( http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html #sysvar_interactive_timeout

You probably need to configure c3p0 to test the connection, like explained here: http://www.mchange.com/projects/c3p0/index.html#configuring_connection_testing 您可能需要配置c3p0来测试连接,如此处所述: http : //www.mchange.com/projects/c3p0/index.html#configuring_connection_testing

It means the network connection between the applicaiton and the database was broken. 这意味着应用程序和数据库之间的网络连接已断开。

This can happen for various reasons (network failure, or connection timeout). 出于各种原因(网络故障或连接超时),可能会发生这种情况。 What the last sentence basically about is how to remedy to the problem. 最后一句话主要是关于如何解决该问题的。

Either you can try to change settings to make the connection less prone to failure/disconnection, or configure the JDBC driver to deal with the failure/disconnection and reconnect automatically. 您可以尝试更改设置以使连接不太容易出现故障/断开连接,或者配置JDBC驱动程序以处理故障/断开连接并自动重新连接。

Note: you should not hold connection directly for prolonged period of time. 注意:您不应长时间直接保持连接。 Obtain a connection from the pool, use it, and release it back to the pool. 从池中获取连接,使用它,然后将其释放回池中。 The pool manages the connections for you. 池为您管理连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM