The base class for SharedPoolDataSource
and PerUserPoolDataSource
. Many of the configuration properties are shared and defined here. This class is declared public in order to allow particular usage with commons-beanutils; do not make direct use of it outside of commons-dbcp.
A J2EE container will normally provide some method of initializing the DataSource
whose attributes are presented as bean getters/setters and then deploying it via JNDI. It is then available to an application as a source of pooled logical connections to the database. The pool needs a source of physical connections. This source is in the form of a ConnectionPoolDataSource
that can be specified via the {@link #setDataSourceName(String)} used tolookup the source via JNDI.
Although normally used within a JNDI environment, A DataSource can be instantiated and initialized as any bean. In this case the ConnectionPoolDataSource
will likely be instantiated in a similar manner. This class allows the physical source of connections to be attached directly to this pool using the {@link #setConnectionPoolDataSource(ConnectionPoolDataSource)} method.
The dbcp package contains an adapter, {@link org.apache.tomcat.dbcp.dbcp2.cpdsadapter.DriverAdapterCPDS}, that can be used to allow the use of DataSource
's based on this class with jdbc driver implementations that do not supply a ConnectionPoolDataSource
, but still provide a {@link java.sql.Driver} implementation.
The package documentation contains an example using Apache Tomcat and JNDI and it also contains a non-JNDI example.
@author John D. McNally
@since 2.0