Hibernate version: 3.0
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: MySQL
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: 14:47:27,895 INFO [STDOUT] com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
STACKTRACE:
java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1902) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2348) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2858) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665) at com.mysql.jdbc.Connection.execSQL(Connection.java:2972) at com.mysql.jdbc.Connection.execSQL(Connection.java:2902) at com.mysql.jdbc.Statement.executeQuery(Statement.java:822) at com.mysql.jdbc.DatabaseMetaData.getTables(DatabaseMetaData.java:4301) at com.mchange.v2.c3p0.impl.NewProxyDatabaseMetaData.getTables(NewProxyDatabaseMetaData.java:2827) at com.mchange.v2.c3p0.impl.DefaultConnectionTester.activeCheckConnection(DefaultConnectionTester.java:71) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.testPooledConnection(C3P0PooledConnectionPool.java:141) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.refurbishIdleResource(C3P0PooledConnectionPool.java:126) at com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:1227) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
Hi,
I'm writing a small program that runs on a localhost tomcat but connects to a MySQL db over the internet to my subscribed domain.
The problem I'm having is that the connection between my machine to the domain is very bad.
If I try to get the session from a factory using connection pooling, it will always give me an error "communication link failure" after just 1 or 2 successful select statement.
I try to configure c3p0 as follow but still I cannot consistently connect to my db
<property name="connection.autoReconnectForPools">true</property>
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.acquireRetryAttempts">2</property>
<property name="c3p0.idle_test_period">5</property>
<property name="c3p0.min_size">1</property>
<property name="c3p0.max_size">2</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.timeout">5</property>
<property name="c3p0.automaticTestTable">C3P0TestTable</property>
<property name="c3p0.testConnectionOnCheckout">true</property>
I manage to get around the problem by supplying my own database connection through
Session s = getSessionFactory().openSession(dbconn);
Is there a way to allow hibernate to fetch a new connection everytime it uses does a db operation? or disable connection pooling?
I have tried
<property name="pooling">false</property>
But still I see the message at initialization of hibernate
"Using Hibernate built-in connection pool (not for production use!)"
Thanks.
Han Ming
|