title: C3p0 failed to reconnect the database when the database is down
body: <p>I've encountered an issue when configuring the c3p0 settings. The senario is: I have one java project which will be started at 3:00 am everyday and then connect to the database to do something. Sometimes, the database may be down at that time and may be recovered after 2 or 3 hours.<br>
  so, I need to make the program try to reconnect the database in a specific time interval to see whether the database is ok, until it can successfully connect to the database.
  I've tried to configure the c3p0 to reconnect the database infinitely until success, but seems it stuck into some deadlock. Below is my c3p0 settings.
  I use c3p0 v0.9.1 with hibernate in Spring framework, the database is DB2.</p>
  
  <pre><code>&lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" &gt;
      &lt;property name="driverClass" value="${jdbc.driverClassName}"/&gt;
      &lt;property name="jdbcUrl" value="${jdbc.url}"/&gt;
      &lt;property name="user" value="root"/&gt;
      &lt;property name="password" value="root"/&gt;
  
      &lt;property name="acquireRetryAttempts" value="0"/&gt;
  
      &lt;property name="acquireRetryDelay" value="10000"/&gt;
  
      &lt;property name="maxIdleTime"value="60"/&gt;
      &lt;property name="minPoolSize" value="5" /&gt;
      &lt;property name="maxPoolSize" value="200"/&gt;
      &lt;property name="idleConnectionTestPeriod" value="30" /&gt;
      &lt;property name="preferredTestQuery" value="values(1)" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>When I run the program, it failed and the error log is shown below:</p>
  
  <pre><code>[WARN]: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@21eb3f -- APPARENT DEADLOCK!!! 
  Creating emergency threads for unassigned pending tasks!
  [WARN]: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@21eb3f -- APPARENT DEADLOCK!!! 
  Complete Status:
   Managed Threads: 3
   Active Threads: 3
   Active Tasks: 
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@15e796d (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@176150c (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@15fc793 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
   Pending Tasks: 
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@127bd04
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1ea8fc0
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@83969e
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1159092
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@c69203
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@9c035a
    com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@a0416a
  Pool thread stack traces:
    ...
  [WARN] [2017-09-04  ThreadPoolAsynchronousRunner.processReplacedThreads() ] Task com.mchange.v2.resourcepol.BasicResourcePool$AcquireTask@15e796d 
  (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt().
  [WARN] [2017-09-04  ThreadPoolAsynchronousRunner.processReplacedThreads() ] Task com.mchange.v2.resourcepol.BasicResourcePool$AcquireTask@176150c 
  (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt().
  [WARN] [2017-09-04  ThreadPoolAsynchronousRunner.processReplacedThreads() ] Task com.mchange.v2.resourcepol.BasicResourcePool$AcquireTask@15fc793 
  (in deadlocked PoolThread) failed to complete in maximum time 60000ms. Trying interrupt().
  
  [WARN] [2017-09-04 BasicResourcePool$AcquireTask.run()] com.mchange.v2.resourcepool.BasicResourcePool@53b9e444 -- Thread unexpectedly interrupted
  while performing an acquisition attempt.
  java.lang.InterruptedException: sleep interrupted
     at java.lang.Thread.sleep(Native Method)
     at com.mchange.v2.resourcepol.BasicResourcePool$AcquireTask.run (BasicResourcePool.java:1805)
     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
  [WARN] [2017-09-04 BasicResourcePool$AcquireTask.run()] com.mchange.v2.resourcepool.BasicResourcePool@53b9e444 -- Thread unexpectedly interrupted
  while performing an acquisition attempt.
  java.lang.InterruptedException: sleep interrupted
     at java.lang.Thread.sleep(Native Method)
     at com.mchange.v2.resourcepol.BasicResourcePool$AcquireTask.run (BasicResourcePool.java:1805)
     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
  [WARN] [2017-09-04 BasicResourcePool$AcquireTask.run()] com.mchange.v2.resourcepool.BasicResourcePool@53b9e444 -- Thread unexpectedly interrupted
  while performing an acquisition attempt.
  java.lang.InterruptedException: sleep interrupted
     at java.lang.Thread.sleep(Native Method)
     at com.mchange.v2.resourcepol.BasicResourcePool$AcquireTask.run (BasicResourcePool.java:1805)
     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
  </code></pre>
  
  <p>Could you please help to correct my if the settings has anything wrong? Thank you in advance!</p>