EOFException in Connector/j
Posted by: Kris Younger
Date: January 03, 2005 01:31PM

So, maybe this is solved somewhere.....

I'm now using 4.1.8 on Redhat 9, with a latest Sun JDK.
I'm using Java Studio Creator (which means I'm using the latest RowSets interface...)

I have also been seeing this in hibernate code, much under the same circumstances.
Every so often, if you google, you find various people hitting this but from very different

AND yet the app mostly works, I get my rows, and can make my inserts and updates...

I'm completely be-devilled by this one. Almost *every* time I do some kind of query I get:
JdbcRowSetXImpl (setTransactionIsolation): Communication link failure: java.io.EOFException, underlying cause: null
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1388)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1532)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1923)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1218)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2233)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2193)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2174)
at com.mysql.jdbc.Connection.setTransactionIsolation(Connection.java:901)
at com.sun.gjc.spi.ConnectionHolder.setTransactionIsolation(ConnectionHolder.java:551)
at com.sun.sql.rowset.JdbcRowSetXImpl.connect(JdbcRowSetXImpl.java:427)
at com.sun.sql.rowset.JdbcRowSetXImpl.prepare(JdbcRowSetXImpl.java:532)
at com.sun.sql.rowset.JdbcRowSetXImpl.execute(JdbcRowSetXImpl.java:349)

And I get this almost constantly - and yes, I have the autoReconnect=true going on and no, this isn't a connection
that has been open for more than 8 hours....

In MySQLIO.java the readFully routine looks like:
private final int readFully(InputStream in, byte[] b, int off, int len)
throws IOException {
if (len < 0) {
throw new IndexOutOfBoundsException();

int n = 0;

while (n < len) {
int count = in.read(b, off + n, len - n);

if (count < 0) {
throw new EOFException();

n += count;

return n;

Now, I'm not the clearest thinking guy on this, but should the block above:
if (count < 0) {
throw new EOFException();
be something else - as in, doesn't count < 0 mean EOF as a standard matter of course??
that there is nothing to read any more and you should return with 'n' set at whatever number of bytes have been read?
and not throw a new Nested Exception? in.read() will return -1 at EOF, otherwise the number of bytes, but what if it returns 0? isn't that a real exception.... on another tack, how about if it did an "count = in.available();" call and only read that number of bytes... (read without blocking...)

My log files have been full of this for months..... it makes debugging really ugly...


Options: ReplyQuote

Written By
EOFException in Connector/j
January 03, 2005 01:31PM

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.