Hibernate version: 2.16
Mapping documents: not included - 1500 lines long
Code between sessionFactory.openSession() and session.close(): not necessary; works fine
Full stack trace of any exception that occurs:
java.net.SocketException: Connection reset by peer: socket write error
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:66)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1664)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1627)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1083)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2051)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1496)
at com.mchange.v2.sql.filter.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:68)
at com.mchange.v2.c3p0.impl.C3P0PooledConnection$2.executeQuery(C3P0PooledConnection.java:567)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
Name and version of the database you are using: MySQL 4.1
Debug level Hibernate log excerpt: n/a
Configuration:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://#host#/#name#?autoReconnect=true</property>
<property name="hibernate.connection.username">#user#</property>
<property name="hibernate.connection.password">#pass#</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.max_fetch_depth">3</property>
<property name="hibernate.cache.provider_class">net.sf.hibernate.cache.OSCacheProvider</property>
<property name="hibernate.connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.minPoolSize">2</property>
<property name="c3p0.maxPoolSize">10</property>
<property name="c3p0.timeout">300</property>
<property name="c3p0.max_statement">50</property>
<property name="c3p0.idle_test_period">300</property>
<property name="c3p0.max_size">100</property>
<mapping resource="hibernate.mapping.xml"/>
</session-factory>
</hibernate-configuration>
Question:
Everything works fine, most of the time. However, I'm using Hibernate in a standalone Swing application, which can go for hours (or even days) without being used, and it doesn't seem to want to re-establish dropped connections. It just throws a SocketException in the MySQL driver code, which is never passed back to the application. I've tried umpteen different ways of configuring the cache and database, I've tried adding ?autoConnect=true to the driver string, but it just doesn't work.
|