Re: Communications link failure due to underlying exception
Posted by: Peter Andrews
Date: July 15, 2005 08:52AM

I was also getting this error and have resolved it.
The error occurs when the MySql database terminates a connection. In my case this occurred after one hour of disuse which is the timeout setting we configured in MySql. I imagine restarting MySql would also cause the problem. After this occurs, despite autoReconnect=true I woudl get the Communication link failure.

I am using Tomcat so my connection properties are specified in the server.xml file lke this:
<ResourceParams name="jdbc/directory">
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>username</name><value>user</value></parameter>
<parameter><name>driverClassName</name><value>com.mysql.jdbc.Driver</value></parameter>
<parameter><name>url</name><value>jdbc:mysql://mycompany.com/directory?autoReconnect=true&amp;jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;maintainTimeStats=false</value></parameter>
<parameter><name>removeAbandoned</name><value>true</value></parameter>
<parameter><name>removeAbandonedTimeout</name><value>60</value></parameter>
<parameter><name>logAbandoned</name><value>true</value></parameter>
<parameter><name>maxActive</name><value>1000</value></parameter>
<parameter><name>maxIdle</name><value>500</value></parameter>
<parameter><name>maxWait</name><value>10000</value></parameter>
</ResourceParams>

Notice the line: <parameter><name>url</name><value>jdbc:mysql://mycompany.com/directory?autoReconnect=true&amp;jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;maintainTimeStats=false</value></parameter>

This works and avoid the Communication link failure. Earlier I had been using:
<parameter><name>connectionProperties</name><value>autoReconnect=true;autoReconnectForPools=true;jdbcCompliantTruncation=false;elideSetAutoCommits=true;useNewIO=false;useLocalSessionState=true;maintainTimeStats=false</value></parameter>
<parameter><name>url</name><value>jdbc:mysql://mycompany.com/search</value></parameter>

which should be equivalent. My guess is that the jdbc Connector/J 3.1.10 driver has a bug dealing with autoReconnect parameters passed via the connectionParameters instead of the queryString portion of the url.

Hope this helps someone!

Options: ReplyQuote


Subject
Written By
Posted
Re: Communications link failure due to underlying exception
July 15, 2005 08:52AM
June 09, 2006 04:42AM
August 24, 2006 05:27PM
July 15, 2007 04:27AM


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.