title: How to create a JDBC MySQL connection pool in Tomcat7 installed on Amazon EC2?
body: <p>I am new and any help will be highly appreciated. I have a Webapp installed on Amazon EC2. I have installed  Tomcat7 and MySQL 5.5 on Amazon EC2.</p>
  
  <p>I am using following code in servlet for JDBC-MySQL connection</p>
  
  <pre><code>        Connection connection;
          Statement statement;
          ResultSet rs = null;
          try {
              // load Connector/J
              Class.forName("com.mysql.jdbc.Driver");
              connection = DriverManager.getConnection(JDBC_MYSQL_STRING);
              System.out.println(TAG + " Connection with MySQL established");
              statement = connection.createStatement();
              ....
              ....
              ....
              rs.close();
              statement.close();
              connection.close();
          } catch (ClassNotFoundException ex) {
              Log.log(Level.SEVERE, "ClassNotFoundException", ex);
          } catch (SQLException e) {
              for (Throwable t : e) {
                  System.out.println(t.getMessage());
              }
  </code></pre>
  
  <p>I have included <code>mysql-connector-java-5.1.13-bin.jar</code> for Connector/J in the Library folder for Netabeans and deployed <code>war</code> files on tomcat7 in Amazon ec2. </p>
  
  <p><strong>My Question</strong>
  I have learned that JDBC-MySQL connection is very time consuming operation and <code>connection pools</code> can be used to keep live connection which will reduce time consumed in connection. I am new to this and have read my blogs but unable to understand how to set up <code>connection pool</code> and how to use it in the servlets?</p>
  
  <p>Thanks.</p>