Re: com.mysql.jdbc.CommunicationsException due to java.io.EOFException...
Posted by: Andrew Trotter
Date: April 15, 2008 07:40AM

Hi,

I'm also experiencing this problem.

NOTE: I HAVEN'T SOLVED IT YET. I'M HOPING THE BELOW WILL.

using tomcat, mysql-connector-java-5.1.6, and Hibernate 3.something to access a mySQl db. if everything is left on overnight, the first connection fails, yet all following connections work fine.

To solve it, i've found a few things(I have yet to test them):

1) Placing these lines in your context.xml file:

<parameter><name>validationQuery</name><value>SELECT 1</value></parameter>
<parameter><name>testOnBorrow</name><value>true</value></parameter>
<parameter><name>testWhileIdle</name><value>true</value></parameter>
<parameter><name>timeBetweenEvictionRunsMillis</name><value>60000</value></parameter>
<parameter><name>numTestsPerEvictionRun</name><value>5</value></parameter>
<parameter><name>minEvictableIdleTimeMillis</name><value>600000</value></parameter>

The last 3 lines are to kill the connection so that it doesn't get quietly terminated(meaning tomcat doesn't notice there's no more connection and tries using it.) I'm most hopeful about these.


2) Placing autoReconnect=true in the database url, or as a parameter.

3) only applicable to hibernate users, add these to hibernate.cfg.xml:

<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="connection.is-connection-validation-required">true</property>

4) also Check classpath to see if any other versions of mySQl/connector-j are there.

5) there was mention of a firewall killing the connection after a certain time, but tomcat not noticing, then trying to use that connection. Doesn't apply to me, but I thought I'd mention it.

I hope this helps somebody. if nothing works, i'll have to keep looking for a solution.

Options: ReplyQuote


Subject
Written By
Posted
Re: com.mysql.jdbc.CommunicationsException due to java.io.EOFException...
April 15, 2008 07:40AM


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.