The connection has failed, possibly due to a firewall idle-timeout, etc. If you don’t have your JDBC driver configured to reconnect on failure, then this error will not go away unless you open a new connection.
If you are using a database connection pool (you are using one, right?), then you probably want to enable it’s connection-checking features like issuing a query to check to see if the connection is working before handing it back to the application. In Apache commons-dbcp, this is called the validationQuery
and is often set to something simple like SELECT 1
.
Since you are using MySQL, you ought to use a Connector/J-specific “ping” query that is lighter-weight than actually issuing a true SQL query and set your validation query to /* ping */ SELECT 1
(the ping part needs to be exact).