Bug #4691 SQLException: java.io.EOFException on Solaris
Submitted: 22 Jul 2004 9:04 Modified: 3 Aug 2004 4:12
Reporter: [ name withheld ] Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.3-beta OS:Solaris (Solaris 8 (SPARC))
Assigned to: Matthew Lord CPU Architecture:Any

[22 Jul 2004 9:04] [ name withheld ]
Description:
The version of MySQL is 4.0.20.
The version of j2sdk is 1.4.2_05.
When I try to connect to MySQL on Solaris8 from Linux9.0 using Java, following error mesage occur.

ErrorCode : 0
NextException : null
SQLState : 08S01
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
 
** BEGIN NESTED EXCEPTION **
 
java.io.EOFException
 
STACKTRACE:
 
java.io.EOFException
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1857)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2267)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2687)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1532)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2273)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2204)
        at com.mysql.jdbc.Statement.executeQuery(Statement.java:1138)
        at com.mysql.jdbc.Connection.loadServerVariables(Connection.java:3203)
        at com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:3080)
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:1699)
        at com.mysql.jdbc.Connection.<init>(Connection.java:402)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:224)
        at java.sql.DriverManager.getConnection(DriverManager.java:512)
        at java.sql.DriverManager.getConnection(DriverManager.java:171)
        at jp.go.jaeri.qbg.Update.main(Update.java:29)
 
 
** END NESTED EXCEPTION **

The source of  Java on Linux9.0 is following.

----- start --------------------
 
import java.net.*;
import java.sql.*;
 
public class Update{
        public static void main(String arg[]){
                String  server  = "172.16.170.12";
                String  db         = "colisnp";
                String  user      = "colisnp";
                String  pass    = "colicoli";
                String  url        = "jdbc:mysql://" + server + "/" + db;
                Connection      con     = null;
                Statement       stmt    = null;
                try{
                        System.out.println("server = [" + server + "]");
                        System.out.println("db = [" + db + "]");
                        System.out.println("user = [" + user + "]");
                        System.out.println("pass = [" + pass + "]");
                        System.out.println("url = [" + url + "]");
                        Class.forName("com.mysql.jdbc.Driver").newInstance();
                        System.out.println("Driver load.");
                        con     = DriverManager.getConnection(url,user,pass);
                        System.out.println("Success Connection!!");
                }catch(SQLException e){
                        System.err.println("Failure Connection..");
                        System.err.println("ErrorCode : " + e.getErrorCode());
                        System.err.println("NextException : " + e.      getNextException());
                        System.err.println("SQLState : " + e.getSQLState());
                        System.err.println(e.toString());
                }catch(Exception e){
                        e.printStackTrace();
                        System.err.println(e.toString());
                }finally{
                        try{
                                if(con!=null){
                                        con.close();
                                        con = null;
                                        System.out.println("Cut out connection");
                                }
                        }catch(Exception e){
 
                        }
                }
        }
}

----- end ---------------

When I try to connect to MySQL(4.0.20) on Solaris8 from the same Solaris8 machine using Java(j2sdk1.4.2_05), same error occur.
But, when I try to connect to MySQL(4.0.20) on Linux9.0 from Linux9.0 using Java(j2sdk1.4.2_05), the connection is success.
And, when I try to connect to MySQL(4.0.20) on Solaris8 from Linux9.0 using 'mysql' command, the connection is success.

What is the problem?

How to repeat:
Try to connect to MySQL(4.0.20) on Solaris8 from Linux9.0 using Java(j2sdk1.4.2_05) code.
[3 Aug 2004 4:12] Matthew Lord
I cannot repeat this using 3.1.3-beta connecting from a Suse 7.3 Linux build 2.4.26 #4 SMP Mon 
Jun 7 00:10:41 CEST 2004 i686 unknown machine to a Solaris 8 SunOS sunfire100c 5.8 
Generic_117000-03 sun4u sparc SUNW,UltraAX-i2.

I tried connecting to the 32 bit and 64 bit versions of 4.0.20 running on solaris 8 and had no 
problems.

java -v
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
[15 Nov 2006 13:31] Max Lam
Hi,

I'd encountered the same problem as well. In fact this issue affects Connector/J version 5.0.4

I'm running on Solaris 10 with MySQL version 5.0.24a.

Unfortunately, it was very difficult to replicate the error. This is an undeterministic error which I couldn't find ways to replicate it. All I did was to run a bunch of stored procedures (meaning calling store procedures like 100000 times).
[10 Feb 2007 15:13] Wojciech Owczarek
Encountering the same error while connecting from a Windows XP box to a MySQL 4.x server on a remote Linux machine with MySQL Connectot/J 5.0.4, I think this error seems to appear in a purely random matter. So, not quite Solaris-specific.
[12 Sep 2007 12:47] Per Lindberg
I'm having the same problem in a timer thread on a Linux box
with server version: 5.0.24a-standard-log.

Curiously, it does not happen on my Windows development box, neither
on other Linux boxen. According to the traceback, the problem occurs
when a new db connection is made. (And yes, I meticously close my connections).

This is really annoying, a show-stopper. Here follows my traceback:

2007-09-11 23:39:49,940  WARN mailtimer at MailTask:39 - Exception in MailTask 'i': 

com.implior.stargate.StargateSystemException: Database driver problem AT  

com.implior.stargate.Utils.getJdbcConnection:392 Utils.ensureDb:119 Utils.ensureDb:95 

Database.<init>:75 DocustoreDatabase.<init>:30 MailTask.doit:81 MailTask.run:36 

TimerThread.mainLoop:512 TimerThread.run:462 CAUSED BY: 

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying 

exception: 

** BEGIN NESTED EXCEPTION ** 

com.mysql.jdbc.CommunicationsException
MESSAGE: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.io.EOFException

STACKTRACE:

java.io.EOFException
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1963)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2375)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:868)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3340)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1238)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2743)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:207)
	at com.implior.stargate.Utils.getJdbcConnection(Utils.java:386)
	at com.implior.stargate.Utils.ensureDb(Utils.java:119)
	at com.implior.stargate.Utils.ensureDb(Utils.java:95)
	at com.implior.stargate.Database.<init>(Database.java:75)
	at com.implior.docustore.DocustoreDatabase.<init>(DocustoreDatabase.java:30)
	at com.implior.stargate.server.MailTask.doit(MailTask.java:81)
	at com.implior.stargate.server.MailTask.run(MailTask.java:36)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)

** END NESTED EXCEPTION **

Last packet sent to the server was 312 ms ago.

STACKTRACE:

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying 

exception: 

** BEGIN NESTED EXCEPTION ** 

java.io.EOFException

STACKTRACE:

java.io.EOFException
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1963)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2375)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:868)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3340)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1238)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2743)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:207)
	at com.implior.stargate.Utils.getJdbcConnection(Utils.java:386)
	at com.implior.stargate.Utils.ensureDb(Utils.java:119)
	at com.implior.stargate.Utils.ensureDb(Utils.java:95)
	at com.implior.stargate.Database.<init>(Database.java:75)
	at com.implior.docustore.DocustoreDatabase.<init>(DocustoreDatabase.java:30)
	at com.implior.stargate.server.MailTask.doit(MailTask.java:81)
	at com.implior.stargate.server.MailTask.run(MailTask.java:36)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)

** END NESTED EXCEPTION **

Last packet sent to the server was 312 ms ago.
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2586)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:868)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3340)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1238)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2743)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:207)
	at com.implior.stargate.Utils.getJdbcConnection(Utils.java:386)
	at com.implior.stargate.Utils.ensureDb(Utils.java:119)
	at com.implior.stargate.Utils.ensureDb(Utils.java:95)
	at com.implior.stargate.Database.<init>(Database.java:75)
	at com.implior.docustore.DocustoreDatabase.<init>(DocustoreDatabase.java:30)
	at com.implior.stargate.server.MailTask.doit(MailTask.java:81)
	at com.implior.stargate.server.MailTask.run(MailTask.java:36)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)

** END NESTED EXCEPTION **

Last packet sent to the server was 313 ms ago., SQL state: 08S01, Error code: 0 AT  

com.mysql.jdbc.Connection.createNewIO:2814 Connection.<init>:1553 

NonRegisteringDriver.connect:266 DriverManager.getConnection:582 

DriverManager.getConnection:207 Utils.getJdbcConnection:386 Utils.ensureDb:119 

Utils.ensureDb:95 Database.<init>:75 DocustoreDatabase.<init>:30 MailTask.doit:81 

MailTask.run:36 TimerThread.mainLoop:512 TimerThread.run:462
[18 Aug 2009 21:14] maxime mart
Hi, I know this bug is opened for quite a while but I think it may be the same problem for me here.

I have a client-server application. The server connect to MySQL and use a connection pool witch renew all its connection every 2 hours. After a couple of days, the server bug throwing the following exception :

 +---Start of stack---+
 com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 
 
 ** BEGIN NESTED EXCEPTION ** 
 
 java.io.EOFException
 
 STACKTRACE:
 
 java.io.EOFException
 	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1845)
 	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
 	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
 	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
 	at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
 	at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
 	at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
 	at accesDB.ResultRequestsDB.Get(Unknown Source)
 	at accesDB.ResultRequestsDB.Get(Unknown Source)
 	at userCommand.serveurtaches.ServeurtachesCommand.getNewTache(Unknown Source)
 	at userCommand.serveurtaches.ServeurtachesCommand.execute(Unknown Source)
 	at server.CommandInvoker$CommandExecuter.run(Unknown Source)
 
 
 ** END NESTED EXCEPTION **
 
 
 	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2504)
 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
 	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
 	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
 	at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
 	at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
 	at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
 	at accesDB.ResultRequestsDB.Get(Unknown Source)
 	at accesDB.ResultRequestsDB.Get(Unknown Source)
 	at userCommand.serveurtaches.ServeurtachesCommand.getNewTache(Unknown Source)
 	at userCommand.serveurtaches.ServeurtachesCommand.execute(Unknown Source)
 	at server.CommandInvoker$CommandExecuter.run(Unknown Source)
 +--- End of stack ---+

The server runs fine for at least 2 days before it stop to work properly. The bug happen when try to consult the DB. This query is executed every 5 seconds.

I suspect it may be the connections that are not closing and MySQL timeout the connection and provoking this error, but i've double checked and the connections are closed regulary.

Any suggestion to where to look ?
[18 Aug 2009 21:21] maxime mart
I forgot to tell the congigs of the server : 

Gentoo Linux 2.6.21

java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)

MySQL Server version: 5.0.44

and i'm using the connector/J : 
mysql-connector-java-5.1.7-bin.jar
[30 Nov 2011 12:38] Andrei Raducu
Same Exception on Linux Fedora Core
with Connector/J 5.0.5