Hi everybody,
I ran into a problem while using Hibernate and Mysql. MySQL closes an unused connection after 28800 sec. I've googled. I thought I've found a solution, but it doesn't work.
For testing purposes I've set the MySQL timeout to 60 sec.
Attempt 1:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <!-- Database connection settings -->
      <property name="connection.driver_class">
         <!-- org.hsqldb.jdbcDriver -->
         com.mysql.jdbc.Driver
      </property>
      <property name="connection.url">
         jdbc:mysql://localhost/xxxx
      </property>
      <property name="connection.username">
         xxxx
      </property>
      <property name="connection.password">
         xxxx
      </property>
      <!-- JDBC connection pool (use the built-in) -->
      <property name="connection.pool_size">1</property>
      [b]<!-- Timeout -->
      <property name="hibernate.c3p0.max_size">1</property> 
      <property name="hibernate.c3p0.idle_test_period">20</property>
      <property name="hibernate.c3p0.timeout">40</property>[/b]
      <!-- SQL dialect -->
      <property name="dialect">
         <!-- org.hibernate.dialect.HSQLDialect -->
         org.hibernate.dialect.MySQLDialect
      </property>
      <!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>
      <!-- Disable the second-level cache  -->
      <property name="cache.provider_class">
         org.hibernate.cache.NoCacheProvider
      </property>
      <!-- Echo all executed SQL to stdout -->
      <property name="show_sql">false</property>
      <!-- Drop and re-create the database schema on startup -->
      <!-- comment this out to disable schema recreation on startup -->
      <!-- <property name="hbm2ddl.auto">create</property> -->
      <property name="hibernate.format_sql">false</property>
      <!-- Auflistung der gemappten Klassen -->
      ....
   </session-factory>
</hibernate-configuration>
Attempt 2: I've changed the bold part to
Code:
[b]<!-- Timeout -->
      <property name="c3p0.max_size">1</property> 
      <property name="c3p0.idle_test_period">20</property>
      <property name="c3p0.timeout">40</property>[/b]
Attempt 3: I've included Hibernate C3P0 ConnectionProvider in version 3.3.1.GA in my project. Then I retried both former attempts, but I can't get it working.
It seems that the configurations I made have no effect.
Any hints? Solutions?
Regards,
Axel