Making a JDBC 1.0 Connection Pool Behave as a JDBC 2.0 Connection Pool
If you can’t find a JDBC 2.0 connection
pool
implementation for your database, there are plenty of implementations
based on JDBC 1.0 available. A popular one is the
DBConnectionBroker
, available at http://www.javaexchange.com/. Another one,
DBCP, is developed by the
Jakarta Commons project: http://jakarta.apache.org/commons/index.html
and is bundled with Tomcat. In this section I describe a couple of
wrapper classes you can use with minimal changes for implementations
like these so they can be used in place of a JDBC 2.0 connection pool
implementation. This way the JSTL database access actions and other
generic database tools can use your wrapped JDBC 1.0 pool, and
it’s easy to replace it with a real JDBC 2.0 pool
when one becomes available from your database vendor or a third
party.
The interaction between the wrapper classes and a connection pool implementation is illustrated in Figure 24-3.
The application calls the DataSourceWrapper
getConnection( )
method. The
DataSourceWrapper
obtains a
Connection
object from its
ConnectionPool
object (which represents the JDBC
1.0 pool implementation). The ConnectionPool
either finds an available Connection
in its pool
or creates a new one. The DataSourceWrapper
creates a new ConnectionWrapper
object for ...
Get JavaServer Pages, 3rd Edition 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.