dbcp to solve the MySQL wait_timeout, there is a friend in need of reference.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:, The, last, packet, successfully, received, from, the, was, server
52587242, milliseconds, ago., The, packet, sent, successfully, to, the, server, was, last,, milliseconds,, ago., 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.
awareness is the latest request for the current connection, which is before 52587 seconds, , this time is .greater than the wait_timeout time configured by the Service
The wait_timeout time for
mysql is 28800 seconds , and the query command is as follows:
mysql>, show, global, variables, like,'wait_timeout',
Variable_name Value |
| | wait_timeout 28800 |
dbcp is the connection pool schema, which is not configured by default. For the database that has been created, it is not active to request the.of the database
for these reasons, obviously, it will cause a long time not to apply connection, which will cause the "wati_timeout" exception.
guarantees at least one query request.per connection in the MySQL wait_timeout time
dbcp can be configured as follows:
timeBetweenEvictionRunsMillis=20000 // check the idle connection
in the connection pool every timeBetweenEvictionRunsMillis milliseconds
TestWhileIdle=true //, that is, when the connection in the connection pool is empty and closed, check
ValidationQuery=SELECT 1 FROM dual / /