Hi,
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)
interactiveClient=true
socketTimeout=0
useLocalSessionState=true
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 0.0.0.0 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.
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)
interactiveClient=true
socketTimeout=0
useLocalSessionState=true
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 0.0.0.0 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.