Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure (2 replies)

$
0
0
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.

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>