title: Tomcat MYSQL Connection still exist after tomcat restart
body: <p>I have two tomcat server.</p>
  
  <hr>
  
  <p>the first one is 192.168.123.181, version tomcat-7.0.40 </p>
  
  <h2><a href="https://i.stack.imgur.com/5hnNR.png" rel="nofollow noreferrer">192.168.123.181</a></h2>
  
  <p>And the second one is 192.168.123.80, version tomcat-9.0.12</p>
  
  <h2><a href="https://i.stack.imgur.com/nT90q.png" rel="nofollow noreferrer">192.168.123.81</a></h2>
  
  <p>I find that when I try to restart the tomcat service for 192.168.123.80, the mysql connection will not be auto-close/auto-release, which always result in this mySQL Error - "Too many connection".</p>
  
  <p>When I enter "service tomcat stop" for 192.168.123.80, the console will show the following message:</p>
  
  <blockquote>
    <p>Using CATALINA_BASE:   /apps/tomcat</p>
    
    <p>Using CATALINA_HOME:   /apps/tomcat</p>
    
    <p>Using CATALINA_TMPDIR: /apps/tomcat/temp</p>
    
    <p>Using JRE_HOME:        /usr</p>
    
    <p>Using CLASSPATH:       /apps/tomcat/bin/bootstrap.jar:/apps/tomcat/bin/tomcat-juli.jar</p>
    
    <p>Kill failed: $CATALINA_PID not set</p>
  </blockquote>
  
  <p>However, when I enter the same command in 192.168.123.181, it will show the following message:</p>
  
  <blockquote>
    <p>Using CATALINA_BASE:   /apps/tomcat</p>
    
    <p>Using CATALINA_HOME:   /apps/tomcat</p>
    
    <p>Using CATALINA_TMPDIR: /apps/tomcat/temp</p>
    
    <p>Using JRE_HOME:        /usr</p>
    
    <p>Using CLASSPATH:       /apps/tomcat/bin/bootstrap.jar:/apps/tomcat/bin/tomcat-juli.jar</p>
    
    <p>Using CATALINA_PID:    /var/run/tomcat.pid</p>
    
    <p>Killing Tomcat with the PID: 18360</p>
  </blockquote>
  
  <p>May somebody teach me how can I config the server so that it will release the mySQL connection after I restart the tomcat service?</p>
  
  <p>** This is how I connect to mysql server, </p>
  
  <p>code at SLO class:</p>
  
  <pre><code>con = ConnectionPool.getConnection();
  </code></pre>
  
  <p>code at ConnectionPool class,</p>
  
  <pre><code> public static Connection getConnection(){
  
       return connectionManager.getConnection();
   }
  
  
  public static class ConnectionManager {
  
      public Connection getConnection(String driverClass, String driverUrl) {
  
          Connection conn = null;
          try {
              conn = DriverManager.getConnection("proxool." + POOLALIAS + ":" + driverClass + ":" + driverUrl;);
  
          } catch (SQLException e) {
              log.err_sys("ConnectionPool.getConnection(): Error -" + e);
          } 
          return conn;
      }
  }
  </code></pre>