Re: Communications link failure due to underlying exception
Date: May 23, 2007 04:29PM
I was running this block of code in a loop (100 times) and it worked sometimes and failed sometimes under MySQL. Under HSQL, it always succeeds.
java.sql.PreparedStatement stmt = con.prepareStatement(
"SELECT MODEL_TASK_TYPE_ID FROM MODEL_TASK_TYPE " +
"WHERE MODEL_TASK_TYPE=? AND MODEL_TYPE=? AND USER_ID=? AND COMPUTER_ID=?");
stmt.setString(1, taskName);
stmt.setString(2, modelType);
stmt.setInt(3, userID);
stmt.setInt(4, computerID);
java.sql.ResultSet rs = stmt.executeQuery();
I got the same error a lot of you did:
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
Two Clues To The Problem:
------------------------
1) The simple select statement above always succeeded when I set a parameter to a value that would match NO rows. For example, if I set the COMPUTER_ID to 9999, I never got an exception.
2) The simple select always succeeded when I dropped a unique constraint on 4 of the columns in the table. No constraint = works.
For now, my hack solution is to leave off the unique key (I still have the foreign keys defined).
Given my clues, it seems to me that the bug lies in MySQL version 5.0.15, not in the Connector/J JDBC driver. I may ask my SysAd to install the latest version to see if that fixes the problem. By the way, I've tried all the versions of the JDBC driver--it makes no difference.
MySQL 5.0.15 under Linux
Java 5 running under Windows
MySQL Connector/J 5.06
I hope this helps someone.
-Jeff
------------ UPDATE ON MAY 24, 2007 ---------------
I updated MySQL to version 5.0.41 and the problem went away.
Edited 2 time(s). Last edit at 05/24/2007 05:01PM by Jeff Smith.