使用 c3p0 和 Hibernate 时出现 Broken pipeline 异常是什么意思
异常是:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:从服务器成功接收的最后一个数据包是在 45569 毫秒前。成功发送到服务器的最后一个数据包是在 45569 毫秒前,比服务器长“wait_timeout”的配置值。您应该考虑在应用程序中使用之前过期和/或测试连接有效性,增加客户端超时的服务器配置值,或使用 Connector/J 连接属性“autoReconnect=true”来避免此问题。
The Exception is :
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能发生的情况是,C3P0 池中的连接被 MySQL 关闭,因为它保持打开状态的时间超过了 Interactive_timeout (http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_interactive_timeout)
您可能需要配置 c3p0 来测试连接,例如此处解释:http://www.mchange.com/projects/c3p0/index.html#configuring_connection_testing
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)
You probably need to configure c3p0 to test the connection, like explained here: http://www.mchange.com/projects/c3p0/index.html#configuring_connection_testing
这意味着应用程序和数据库之间的网络连接已断开。
发生这种情况的原因有多种(网络故障或连接超时)。最后一句话主要讲的是如何解决这个问题。
您可以尝试更改设置以使连接不易发生故障/断开连接,或者配置 JDBC 驱动程序以自动处理故障/断开连接并重新连接。
注意:不应长时间直接保持连接。从池中获取连接,使用它,并将其释放回池中。池为您管理连接。
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.
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.