// Connecting to a MySQL database via JDBC with connection pooling

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

private Connection conn;

public void init()
   {
   // get JDBC connection to MySQL database from a connection pool.
   // Jar containing the Connector/J JDBC driver: mysql-connector-java-5.1.10-bin.jar must be downloaded and placed on the classpath.
   // You must configure to allow external TCP/IP connections or else localhost won't work either.
   try
      {
      Class.forName( "com.mysql.jdbc.Driver" );
      }
   catch ( Exception e )
      {
      System.out.println( "can't load MySQL driver: " + e.getMessage() );
      }
   try
      {
      // presumably some of this code should be moved to a static init.

       GenericObjectPool cp = new GenericObjectPool( null );
       DriverManagerConnectionFactory dmcf = new DriverManagerConnectionFactory( "jdbc:mysql://localhost/allaboutsquirrels?user=myuserid&password=mypassword" ); );
       PoolableConnectionFactory pcf = new PoolableConnectionFactory( dmcf, cp, null, null, false, true );
       PoolingDataSource ds = new PoolingDataSource( cp );

      // get connection from pool to the allaboutsquirrels database
      conn = ds.getConnection();
      }
   catch ( SQLException e )
      {
      System.out.println( "can't connect to MySQL: " + e.getMessage() );
      }
   }
...

// create the shell into which you can pour an SQL command.
Statement stmt = conn.createStatement();