Hello guys,
I have a problem in mysql with hibernate.
I guess mysql automatically kills open connections after there are not used for a given time. Since my singleton session factory cannot re-open the connection, all my queries fail.
I faced this problem both in mysql 4.1 and mysql 5.0
here is the exception,
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:1934)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2380)
My hibernarte-config file is like below, I've tried all
autoReconnect stuff but still no solution! Can anyone suggest a solution?
PS: mysqlconnector version is : 3.1.11
Code:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">false</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql:///test?autoReconnect=true</property>
<property name="connection.username">test</property>
<property name="connection.password">test</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="current_session_context_class">thread</property>
<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="connection.is-connection-validation-required">true</property>
<property name="connection.charset">UTF-8</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.timeout">18000</property>
<property name="c3p0.acquireRetryAttempts">30</property>
<property name="c3p0.acquireIncrement">5</property>
<property name="c3p0.automaticTestTable">C3P0TestTable</property>
<property name="c3p0.idleConnectionTestPeriod">36000</property>
<property name="c3p0.initialPoolSize">20</property>
<property name="c3p0.maxPoolSize">100</property>
<property name="c3p0.maxIdleTime">1200</property>
<property name="c3p0.maxStatements">50</property>
<property name="c3p0.minPoolSize">10</property>
<property name="connection.charset">UTF-8</property>
</hibernate-configuration>
best regards