After the page is not operated for a long time, the program will report an error when the page is operated again. The exception is as follows:
Com. mysql. jdbc. exceptions. jdbc4.CommunicationsException: Communications link failure
Thelast packet successfully received from the server was 8,064,672 millisecondsago. The last packet sent successfully to the server was 8,064,672 millisecondsago.
At sun. reflect. NativeConstructorAccessorImpl. newInstance0 (Native Method)
Atsun. reflect. NativeConstructorAccessorImpl. newInstance (NativeConstructorAccessorImpl. java: 39)
Atsun. reflect. delegatingconstruct%cessorimpl. newInstance (delegatingconstruct%cessorimpl. java: 27)
At java. lang. reflect. Constructor. newInstance (Constructor. java: 513)
At com. mysql. jdbc. Util. handleNewInstance (Util. java: 409)
At com. mysql. jdbc. SQLError. createCommunicationsException (SQLError. java: 1122)
At com. mysql. jdbc. MysqlIO. send (MysqlIO. java: 3317)
At com. mysql. jdbc. MysqlIO. sendCommand (MysqlIO. java: 1941)
At com. mysql. jdbc. MysqlIO. sqlQueryDirect (MysqlIO. java: 2114)
At com.mysql.jdbc.ConnectionImpl.exe cSQL (ConnectionImpl. java: 2696)
Atcom.mysql.jdbc.PreparedStatement.exe cuteInternal (PreparedStatement. java: 2105)
At com.mysql.jdbc.PreparedStatement.exe cuteQuery (PreparedStatement. java: 2264)
At org.apache.commons.dbcp.DelegatingPreparedStatement.exe cuteQuery (DelegatingPreparedStatement. java: 96)
Atorg.apache.commons.dbcp.DelegatingPreparedStatement.exe cuteQuery (DelegatingPreparedStatement. java: 96)
Atorg.apache.commons.dbcp.DelegatingPreparedStatement.exe cuteQuery (DelegatingPreparedStatement. java: 96)
...
Caused by: java.net. SocketException: Connection reset by peer: socket writeerror
At java.net. SocketOutputStream. socketWrite0 (Native Method)
At java.net. SocketOutputStream. socketWrite (SocketOutputStream. java: 92)
At java.net. SocketOutputStream. write (SocketOutputStream. java: 136)
At java. io. BufferedOutputStream. flushBuffer (BufferedOutputStream. java: 65)
At java. io. BufferedOutputStream. flush (BufferedOutputStream. java: 123)
At com. mysql. jdbc. MysqlIO. send (MysqlIO. java: 3298)
... 34 common frames omitted
The reason is that the timeout time for DBCP connection persistence is longer than that for MySQL connection. The wait_timeout value in mysql configuration must be greater than or equal to the idle_timeout value of the connection pool. Otherwise, mysql will close the connection after the wait_timeout time. However, the connection pool still considers the connection to be available, resulting in an exception.
Connect to the server through the MySQL client to view the current configuration.