Re: Connector/J "Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
Posted by: Gang Lau
Date: February 11, 2008 11:41PM

I saw the same error after I changed connectorJ 3.1.10 to 5.1.5 last night.Before it is ok.

MySQL DB and J2SE program are in the same machine, using to connect.Using hibernate 3.0 and our own very simple connection pool implementation.

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

GNU/Linux Version: CentOS release 4.6 (Final)
[root@kk2 ~]# uname -a
Linux kk2 2.6.9-67.0.4.ELsmp #1 SMP Sun Feb 3 07:08:57 EST 2008 i686 i686 i38 6 GNU/Linux

MySQL Version:
mysql> status
mysql Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i686) using readline 4.3

Connection id: 212
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 4.1.20
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 2 hours 55 min 55 sec

Threads: 16 Questions: 1719338 Slow queries: 1 Opens: 47 Flush tables: 1 Open tables: 41 Queries per second avg: 162.893

2008-02-12 11:27:40,830 [THREAD_POOL_THREAD_28] ERROR org.hibernate.transaction.JDBCTransaction - JDBC begin failed
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at com.mysql.jdbc.Util.handleNewInstance(
at com.mysql.jdbc.SQLError.createCommunicationsException(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.ConnectionImpl.execSQL(
at com.mysql.jdbc.ConnectionImpl.setAutoCommit(
at org.hibernate.transaction.JDBCTransaction.begin(
at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(
at org.hibernate.jdbc.JDBCContext.beginTransaction(
at org.hibernate.impl.SessionImpl.beginTransaction(
at util.ThreadPool$
Caused by: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
... 14 more

Options: ReplyQuote

Written By
Re: Connector/J "Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
February 11, 2008 11:41PM

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.