Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

problems with database connection on a linux tomcat server

  Asked By: Sienna    Date: May 27    Category: Java    Views: 962

I having problem with Mysql 5.0.15-standard and hibernate 3.2.4.sp1. I have Hibernate config file with autoreconnect=true and other settings. after 1 or 2 hours I lose my connection and get following exceptions.

I've tried every version of the JDBC driver from 3 to 5.1.6.

Has anyone found a solution for this problem?

With Best Regards
Mohammad Mahdi Tilab

I get following exceptions:

Stack Trace:

11:02:48,131 WARN [JDBCExceptionReporter:77] SQL Error: 0, SQLState: 08S01

11:02:48,134 ERROR [JDBCExceptionReporter:78] Communications link failure due to underlying exception:


MESSAGE: Broken pipe


java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2689)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2618)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1551)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:930)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1024)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)



2 Answers Found

Answer #1    Answered By: Adalia Fischer     Answered On: May 27

Are you using a connection  pool? If so, make sure you advise your connection pool to test connections before handing them out of the pool. This is necessary with MySQL because it aggressively closes idle connections and since connections in a connections pool are mostly chilling, they are broken after a while and without any notice.

Answer #2    Answered By: Tracy Myers     Answered On: May 27

Try these to settings  for hibernate


I think it would salve your problem
the thing is our application is using spring 2 hibernate  3.2 and mysql
5.0.22 and is working really good

Didn't find what you were looking for? Find more on problems with database connection on a linux tomcat server Or get search suggestion and latest updates.