C3P0 MYSQL connection failure problem

 Since the default wait_timeout of the Mysql server is 8 hours, that is to say, if a connection is idle for more than 8 hours, Mysql will automatically disconnect the connection. However, if the connections in the C3P0 pools are idle for more than 8 hours, Mysql will disconnect them, and C3P0 does not know that the connection has expired. If a client requests a connection at this time, C3P0 will provide the expired Connection to the client, which will cause abnormal. The solution can be: 1. Add autoReconnect=true to jdbcUrl 2. Since autoReconnect=true has been deprecated in the new connector/J version, the document recommends not to use it. So configure the parameters idleConnectionTestPeriod, automaticTestTable

 

However, configuring automaticTestTable will report CLOSE BY CLIENT STACK TRACE, so choose to configure preferredTestQuery instead of automaticTestTable.

Quoted from: http://blog.csdn.net/hallelujah_chen/article/details/6016132

Guess you like

Origin blog.csdn.net/sunnyfirefox/article/details/47777085