The Answer to Life, the Universe, and Everything

Monday, July 30, 2007

Tomcat & MySQL connection Error

Long absense after establishing the connection to MySQL from Hibernate, you might face the error below:
,406 ERROR JDBCExceptionReporter - Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTIOROR JDBCExceptionReporter - Communications link failure due to underlying exception

java.io.EOFException
STACKTRACE:

java.io.EOFException
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1956)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2368)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2867)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1616)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1708)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3255)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1293)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1428)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
.....


Then you can add the following setting in configuration file of hibernate.
jdbc:mysql://localhost:3306/ichannel?autoReconnect=true