title: Hibernate, C3P0, Mysql -- Broken Pipe
body: <p>MySQL seems to have an 8 hour time out on its connections. I'm running multiple WARs in Tomcat utilizing Hibernate for ORM. After 8 hours (i.e. overnight), I get broken pipes when it picks up an idle connection.</p>
  
  <p>I've already traced through the code and made doubly sure I commit or rollback all transactions.</p>
  
  <p>Here is my hibernate.cfg.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
      &lt;property name="hibernate.bytecode.use_reflection_optimizer"&gt;false&lt;/property&gt;
      &lt;property name="hibernate.connection.driver_class"&gt;org.gjt.mm.mysql.Driver&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost/test&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt;
      &lt;property name="hibernate.transaction.factory_class"&gt;org.hibernate.transaction.JDBCTransactionFactory&lt;/property&gt;
      &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
      &lt;!--property name="hibernate.show_sql"&gt;true&lt;/property&gt;
      &lt;property name="hibernate.format_sql"&gt;true&lt;/property--&gt;
  
      &lt;property name="c3p0.min_size"&gt;3&lt;/property&gt;
      &lt;property name="c3p0.max_size"&gt;5&lt;/property&gt;
      &lt;property name="c3p0.timeout"&gt;1800&lt;/property&gt;
      &lt;property name="c3p0.preferredTestQuery"&gt;SELECT 1&lt;/property&gt;
      &lt;property name="c3p0.testConnectionOnCheckout"&gt;true&lt;/property&gt;
      &lt;property name="c3p0.idle_test_period"&gt;100&lt;/property&gt; &lt;!-- seconds --&gt;
  
      &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
      &lt;property name="cache.use_query_cache"&gt;false&lt;/property&gt;
      &lt;property name="cache.use_minimal_puts"&gt;false&lt;/property&gt;
      &lt;property name="max_fetch_depth"&gt;10&lt;/property&gt;
  
      &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
  
      &lt;!-- classes removed --&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>The parameter I thought would have fixed it was the <code>c3p0.idle_test_period</code> -- It defaults to 0.  However, we still have the Broken Pipe issue after 8 hours of running. While there are multiple posts index via Google, none arrive at a satisfactory answer.</p>