简体   繁体   中英

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 )

You probably need to configure c3p0 to test the connection, like explained here: 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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