title: Tomcat JDBC connection pool (releasing connection)
body: <p>Referring to <a href="http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html" rel="noreferrer">Tomcat JBDC connection pool</a>, I see in the standalone java example given there, one gets the connection using <code>datasource.getConnection()</code>which is cool. But in the finally block, it says <code>con.close()</code>.</p>
  
  <p>Question: When I implement this, it seems obvious that the <code>con</code> I get from datasource will be closed every time in the finally. When this is closed, will the connection pooling mechanism acquire a new connection and adds it to the pool? </p>
  
  <p>I presume there should be a method call like <code>releaseConnection()</code> that will let the pool take its own decision whether to close it or let it be open for some other use.</p>
  
  <p>I've also tried doing this <code>ConnectionPool aPool = datasource.createPool();</code>
  But I see there is nothing like release connection on this <code>aPool</code>.</p>
  
  <p>I think I'm missing something here?
  Appreciate your help.</p>
  
  <p>Code snippet from <a href="http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html" rel="noreferrer">Tomcat JBDC connection pool</a>:</p>
  
  <pre><code>            DataSource datasource = new DataSource();
              datasource.setPoolProperties(p); 
  
              Connection con = null;
              try {
                con = datasource.getConnection();
                Statement st = con.createStatement();
                ResultSet rs = st.executeQuery("select * from user");
                int cnt = 1;
                while (rs.next()) {
                    System.out.println((cnt++)+". Host:" +rs.getString("Host")+
                      " User:"+rs.getString("User")+" Password:"+rs.getString("Password"));
                }
                rs.close();
                st.close();
              } finally {
                if (con!=null) try {con.close();}catch (Exception ignore) {}
              }
  </code></pre>