Numerous people have reported this exception over recent years. For me, it has occurred when MySQL is on localhost and I am accessing it with Connector-J; the exception is raised sporadically on a lightly loaded website. I have tried various solutions that other people have suggested:
I have updated to the latest version of Connector-J (5.1.14)
I have
props.setProperty("autoReconnect","true");
props.setProperty("autoReconnectForPools","true");
props.setProperty("reconnectAtTxEnd","true");
for opening the connection to the database.
I have tried
try {stmt.executeQuery("/* ping */ select 1");} catch (Exception ex) {}
prior to each request.
None have solved the problem. The only way that I have found so far to be reliable is to open the connection to the database prior to each request.
I have updated to the latest version of Connector-J (5.1.14)
I have
props.setProperty("autoReconnect","true");
props.setProperty("autoReconnectForPools","true");
props.setProperty("reconnectAtTxEnd","true");
for opening the connection to the database.
I have tried
try {stmt.executeQuery("/* ping */ select 1");} catch (Exception ex) {}
prior to each request.
None have solved the problem. The only way that I have found so far to be reliable is to open the connection to the database prior to each request.