title: Tomcat Connection Pool abandoned issue
body: <p>I'm struggling with a Tomcat connection pool error.The below error is thrown at runtime after running a simple stored procedure that generates a String value.</p>
  
  <pre><code>WARNING: Connection has been abandoned PooledConnection[ConnectionID:45 ClientConnectionId: 7817280c-3f7e-4239-a009-3aedd0a855e8]:java.lang.Exception
      at org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1096)
      at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:799)
      at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:648)
      at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:200)
      at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
      at util.ThreadLocalUtil.getConnection(ThreadLocalUtil.java:55)
      at webapp.dao.WebApplicationDAO.getConnection(WebApplicationDAO.java:30)
      at webapp.dao.AccountDAO.generateAccountId(AccountDAO.java:827)
      at webapp.bo.Account.generateUserAccountId(Account.java:285)
      at webapp.actions.AddUserAccountUNZAction.execute(AddUserAccountUNZAction.java:79)
      at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
      at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
      at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
  </code></pre>
  
  <p>My knowledge of that error is that a connection was opened and not closed. The connection is opened when running the stored proc in the account dao. Below is the block of code which calls the stored procedure. </p>
  
  <pre><code>Connection conn = null;
      CallableStatement stmt = null;
      ResultSet rs = null;
      try {
  
          conn = getConnection();
          stmt = conn.prepareCall(sqlWebAppGenerateUserId);
          stmt.setString(1, base);
          rs = stmt.executeQuery();
          String res = null;
          if (rs.next()) {
              res = rs.getString(1);
          }
  
          if (res == null) {
              throw new RuntimeException("Failed to generate user id.");
          }
  
          return res;
      } catch (SQLException e) {
          LOG.error("{}", e);
          throw new RuntimeException(e);
      }finally {
          if (stmt != null) {
              try {
                  stmt.close();
              } catch (SQLException e) {
                  LOG.error(e.getMessage(), e);
              }
          }
          if (rs != null) {
              try {
                  rs.close();
                  conn.close();
              } catch (SQLException e) {
                  LOG.error(e.getMessage(), e);
              }
          }
  
      }
  </code></pre>
  
  <p>As you can see, I'm using a finally block to close the connection etc.</p>
  
  <p>I'm at a loss to explain the reason why the error is being thrown still and as to how I can debug and solve this issue. Any help would be greatly appreciated</p>