title: Which is a better way to handle connection pooling?
body: <p>I'm trying to implement connection pooling for a JSF 2.1 application which has a H2 database and Jetty 9 Web server embedded in it. I have two options to implement connection pooling for the h2 database. The options being let Jetty implement connection pooling for me, or I define a application scoped managed bean which creates connection pool. I would like to know which would be a better approach in handling connection pooling?</p>
  
  <p>Connection pooling using Application scoped managed bean:</p>
  
  <pre><code>JdbcConnectionPool cp = JdbcConnectionPool.create(
               "jdbc:h2:~/test", "sa", "sa");
           for (String sql : args) {
               Connection conn = cp.getConnection();
               conn.createStatement().execute(sql);
               conn.close();
           }
           cp.dispose();
  </code></pre>