title: Hibernate, Tomcat hangs after a while
body: <p>Im running my tomcat on amazon vm, with amazon RDS, recently i noticed that if RDS has to restart then my webapp loses connection to it and no api requests would complete. That's when i discovered connection pool for hiberante c3p0. </p>
  
  <p>My most recent issue is that after 6-12  hours of running tomcat would stop responding to the requests, then once i go to the tomcat server status i can see this on Threads</p>
  
  <pre><code> Max threads: 200 Current thread count: 150 Current thread busy: 150..
  </code></pre>
  
  <p>Also with stock of api calls that is being holed with huge response time.
  However on memory everything seems alright.
  It almost feels like after some time hibernate starts to hang? although the number of connections on sql server is pretty low, less than 10. </p>
  
  <p>I'm pretty sure i have something wrong in my hibernate config file, could please someone see if that see anything weird in there,</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
              &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://myapp.amazon.us-west-2.rds.amazonaws.com:3306&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt;
          &lt;!--&lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;--&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
  
  
          &lt;property name="hibernate.connection.username"&gt;&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;password&lt;/property&gt;
          &lt;property name="hibernate.default_schema"&gt;default_schema&lt;/property&gt;
  
          &lt;property name="hibernate.connection.autoReconnect"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
  
  
          &lt;!--Settings for c3p0 connection pool--&gt;
          &lt;property name="connection.provider_class"&gt;org.hibernate.connection.C3P0ConnectionProvider&lt;/property&gt;
          &lt;property name="hibernate.c3p0.acquire_increment"&gt;1&lt;/property&gt;
          &lt;property name="hibernate.c3p0.idle_test_period"&gt;60&lt;/property&gt;
          &lt;property name="hibernate.c3p0.min_size"&gt;1&lt;/property&gt;
          &lt;property name="hibernate.c3p0.max_size"&gt;50&lt;/property&gt;
          &lt;property name="hibernate.c3p0.max_statements"&gt;50&lt;/property&gt;
          &lt;property name="hibernate.c3p0.timeout"&gt;30&lt;/property&gt;
          &lt;property name="hibernate.c3p0.acquireRetryAttempts"&gt;1&lt;/property&gt;
          &lt;property name="hibernate.c3p0.acquireRetryDelay"&gt;300&lt;/property&gt;
  
          &lt;!--&lt;property name="hibernate.c3p0.breakAfterAcquireFailure"&gt;false&lt;/property&gt;--&gt;
  
  
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.use_sql_comments"&gt;true&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;!--&lt;property name="hibernate.c3p0.preferredTestQuery"&gt;select 1&lt;/property&gt;--&gt;
          &lt;!--&lt;property name="hibernate.c3p0.testConnectionOnCheckout"&gt;true&lt;/property&gt;--&gt;
          &lt;!--=======================--&gt;
  
  
          &lt;mapping resource="/mappings/...&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Best regards</p>