title: db pool connections closed after war file is undeployed
body: <p>Historically we do a full Tomcat stop/restart after deplying an update. We're switching to using Tomcat manager and redeploy new versions of a war files and in some cases also deploying a war file with a version suffix (e.g. mywar.war##1234) using CodeHaus Cargo. While HikariCP has worked smoothly in the past we're now seeing FATAL errors after Maven and Cargo do a deploy/redoploy. The error is:</p>
  <p>[FATAL] java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.</p>
  <p>I've tried adding singleton=&quot;true&quot; to the GlobalResources and each JNDI but that didn't solve the issue.</p>
  <p>Note: our JNDI datasources are defined in ~tomcat/conf/server.xml in GlobalNamingResources and they are referenced in each war file's context.xml</p>
  <p>Here is the JNDI config. Also, what is the correct MySQL wait_timeout value to use? It is currently set to 60 (60 seconds) which is slightly higher than the maxLifetime in our jdbc setings (55000ms or 55 seconds)</p>
  <pre><code>    &lt;Resource name=&quot;jdbc/global_mysql&quot; auth=&quot;Container&quot; 
  factory=&quot;com.zaxxer.hikari.HikariJNDIFactory&quot;
  type=&quot;javax.sql.DataSource&quot;
  minimumIdle=&quot;1&quot; 
  singleton=&quot;true&quot;
  maximumPoolSize=&quot;3&quot;
  maxLifetime=&quot;55000&quot;
  connectionTimeout=&quot;300000&quot;
  driverClassName=&quot;com.mysql.cj.jdbc.Driver&quot;
  dataSource.implicitCachingEnabled=&quot;true&quot; 
  dataSource.user=&quot;&lt;user&gt;&quot;
  dataSource.password=&quot;&lt;password&gt;&quot;
  dataSource.cachePrepStmts=&quot;true&quot;
  dataSource.prepStmtCacheSize=&quot;250&quot;
  dataSource.prepStmtCacheSqlLimit=&quot;2048&quot;
  dataSource.useServerPrepStmts=&quot;true&quot;
  dataSource.useLocalSessionState=&quot;true&quot;
  dataSource.rewriteBatchedStatements=&quot;true&quot;
  dataSource.cacheResultSetMetadata=&quot;true&quot;
  dataSource.cacheServerConfiguration=&quot;true&quot;
  dataSource.elideSetAutoCommits=&quot;true&quot;
  dataSource.maintainTimeStats=&quot;false&quot;
  jdbcUrl=&quot;jdbc:mysql://&lt;host&gt;:3306/db&quot;
  /&gt;
  </code></pre>