Communications link failure - when connection string doesnot point to localhost mySQL
Posted by: Kulbhushan Sharma
Date: March 27, 2017 07:02AM


We are getting a strange issue while connecting to mySQL.

When we connect application with database using "localhost:port" connection string, our application works fine. However, when we change it to use "ip address:host", application works fine in beginning but after idling for say 5 minutes, is not able to fetch data from database and results in exception below.

Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

I have read multiple blogs and tried several connection string settings listed below (unsuccessfully)

Further to this, I have also tried setting few timeout server variables including "net_read_timeout" to higher values. This also has not worked.

There are more blogs advising changing to My.cnf to comment skip-networking or bind address at server side. However, I have not tried it. In some other blogs, there is also mention of validating the connection object before using it. However, my application has old design where connections are stored in Session object at time of login and reused later. Changing complete application is not possible at this moment.

My SQL Workbench is also behaving in similar way and I need to keep taking additional connection.

I am using my mysql-connector-java-5.1.41 with apache-tomcat-7.0.67 and am not using connection pool. My code uses DriverManager class to get connection.

Till few weeks back, it used to work fine and I am not able trace back when it broke and started working in this manner.

Any help will be really appreciated.

Options: ReplyQuote

Written By
Communications link failure - when connection string doesnot point to localhost mySQL
March 27, 2017 07:02AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.