The Java code for JDBC Connection Pool.
There are two overloaded constructors for creating the connections pool
ConnectionPool pool = new ConnectionPool("jdbc:mysql://host:port/dbname","username","password", "divername");
ConnectionPool pool = new ConnectionPool("jdbc:mysql://host:port/dbname","username","password", "divername", poolSize, cleanupInterval);
Connection connection = pool.checkout();
pool.checkin(connection);
We don't need to close the connection, it will automatically close the unused connection and maintain constant number of connections in the pool.