title: On GlassFish got max pool size exception because of cannot close connection created from DataSource
body: <p>I got max pool size exception on GlassFish when open connection from DataSource although open and close function coupled manually. I google all around but there is no answer! 
  Could anyone help me?</p>
  
  <p>My code snippet as following: (my setting initial connection pool: 8, max-pool-size: 32, Idle Timeout: 300s, max-wait-time: 60s)
  got exception max pool size when call work() function</p>
  
  <pre><code>public class BP{
  
      @Resource(name="BP", type = javax.sql.DataSource.class)
  
      private DataSource ds;
  
  
  
      public void work(){
          for(int i = 0; i &lt; 50; i++){
              doSomething();
          }
      }
      public void doSomething(){
          java.sql.Connection conn = null;        
          CallableStatement cs = null;
          ResultSet rs = null;        
          try{
              conn = ds.getConnection();
              cs = conn.prepareCall("{ call get_bank(?,?) }");
              cs.setString(1, "test");
              cs.registerOutParameter(2, OracleTypes.CURSOR);         
              cs.execute();
              rs = (ResultSet) cs.getObject(2);/
  
              // do something
              //...       
          } catch (Exception e) {            
              e.printStackTrace();
          }finally{
              if (rs != null) {
                try {
                  rs.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
              }
  
              if (cs != null) {
                try {
                  cs.close();
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
  
              if (conn != null) {
                try {
                  conn.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
              }
          }       
      }
  }
  </code></pre>
  
  <p>Ouput:</p>
  
  <pre><code>Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.
  </code></pre>