title: Java Hibernate/C3P0 error: "Could not obtain connection metadata. An attempt by a client to checkout a Connection has timed out."
body: <p>I'm trying to get some code I was passed up and running. It appears to use the Hibernate framework. I've gotten past most of the errors tweaking the configuration, but this one has me dead stumped.</p>
  
  <p>It's trying to connect to two databases: gameapp and gamelog. Both exist. It seems to have issues connecting to gamelog, but none connecting to gameapp (later in the init, it connects to and loads other DBs just fine). Below, I've pasted the error and exception stack dump.</p>
  
  <p>I imaging there's something else in the configs, so I've also included the configuration file for that db. I know this is very vague, but I'm hoping some pro can see the stupid mistake I'm missing.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="GBK"?&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="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
          &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="connection.url"&gt;jdbc:mysql://127.0.0.1:3306/gamelog&lt;/property&gt;
          &lt;property name="connection.username"&gt;root&lt;/property&gt;
          &lt;property name="connection.password"&gt;&lt;/property&gt;
          &lt;property   name="connection.useUnicode"&gt;true&lt;/property&gt;     
              &lt;property   name="connection.characterEncoding"&gt;UTF-8&lt;/property&gt;   
          &lt;property name="hibernate.jdbc.batch_size"&gt;100&lt;/property&gt;
          &lt;property name="jdbc.fetch_size"&gt;1&lt;/property&gt;
          &lt;property name="hbm2ddl.auto"&gt;none&lt;/property&gt;&lt;!-- update --&gt;
          &lt;property name="connection.useUnicode"&gt;true&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;!-- c3p0-configuration --&gt;
          &lt;property name="hibernate.connection.provider_class"&gt;org.hibernate.connection.C3P0ConnectionProvider&lt;/property&gt; 
          &lt;property name="hibernate.c3p0.min_size"&gt;5&lt;/property&gt;
          &lt;property name="hibernate.c3p0.max_size"&gt;10&lt;/property&gt;
          &lt;property name="hibernate.c3p0.timeout"&gt;30&lt;/property&gt;
          &lt;property name="hibernate.c3p0.idle_test_period"&gt;30&lt;/property&gt;
          &lt;property name="hibernate.c3p0.max_statements"&gt;0&lt;/property&gt;
          &lt;property name="hibernate.c3p0.acquire_increment"&gt;5&lt;/property&gt;      
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Exception and stack trace:</p>
  
  <pre><code>2010-04-30 17:50:00,411 WARN [org.hibernate.cfg.SettingsFactory] - Could not obtain connection metadata
  java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
      at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
      at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
      at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527)
      at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
      at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
      at com.database.hibernate.util.HibernateFactory.&lt;init&gt;(Unknown Source)
      at com.database.hibernate.util.HibernateUtil.&lt;clinit&gt;(Unknown Source)
      at com.server.databaseop.goodOp.GoodOpImpl.initBreedGoods(Unknown Source)
      at com.server.databaseop.goodOp.GoodOpImpl.access$000(Unknown Source)
      at com.server.databaseop.goodOp.GoodOpImpl$1.run(Unknown Source)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:165)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:636)
  Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@ca470 -- timeout at awaitAvailable()
      at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317)
      at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
      at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
      at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
      ... 18 more
  </code></pre>