title: MySQL connections not closing
body: <p>I have a web application running on Tomcat7 that connects to MySQL 5.5.</p>
  
  <p>I have two servers running the identical code:</p>
  
  <ul>
  <li><p>Ubuntu</p></li>
  <li><p>Red Hat</p></li>
  </ul>
  
  <p>The Ubuntu one runs fine maintaining a steady 8-16 connections, but the Red Hat one leaks connections and the connection count grows, never going down.  The server eventually resets ~152 connections.</p>
  
  <p>The code to close the connection is getting called:</p>
  
  <pre><code>try {
      conn.close();           
  } catch (SQLException e) {
      exceptionController.logException(this.getClass().getSimpleName(), "finalize Db", e.getMessage(), false);
  }finally{
      conn = null;
  }
  </code></pre>
  
  <p>All connections to MySQL are from this app.</p>
  
  <p>Why the difference in behavior?  <strong>Are there configuration settings that I should be considering - like closing sleeping connections setting</strong>?</p>
  
  <p><strong>Ubuntu Server Status:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/7EsB7.png" alt="enter image description here"></p>
  
  <p><strong>Red Hat Server Status:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/uymG4.png" alt="MySQLWorkbench Server Status Screen"></p>
  
  <p><strong>Partial screen of the connection list:</strong>
  <img src="https://i.stack.imgur.com/XdSAW.png" alt="MySQLWorkbench Server Connection List"></p>
  
  <p>I found this <a href="https://dba.stackexchange.com/questions/1558/how-long-is-too-long-for-mysql-connections-to-sleep">post</a>, which appears to have slowed o/s connections, but they still are creeping up.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Research is pointing to the connections not closing properly.  Why would the connections close in one environment but not another?</p>
  
  <p>I have edited <code>my.cnf</code> with the following setting:</p>
  
  <pre><code>wait_timeout=30
  </code></pre>
  
  <p>However, client connections are sleeping and never getting killed.  The server has been restarted with the new setting in place.</p>
  
  <p>What am I not understanding?</p>