Using a JDBC Connection Pool
There are two classes that we must define in order to create a connection pool: a pooled connection and the connection pool itself. These objects are described in the following sections.
A Pooled JDBC Connection
The PooledConnection object simply wraps a JDBC Connection object in a class that holds the Connection and a flag that determines if the Connection is in use or not. This object is shown in Listing 14.1.
Code Listing 14.1. PooledConnection.java
package com.purejsp.connectionpool; import java.sql.*; public class PooledConnection { // Real JDBC Connection private Connection connection = null; // boolean flag used to determine if connection is in use private boolean inuse = false; // Constructor that takes ... |
Get Pure Java Server Pages™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.