# Package org.apache.commons.dbcp2.cpdsadapter

This package contains one public class which is a `ConnectionPoolDataSource` (CPDS) implementation that can be used to adapt older `Driver` based JDBC implementations.

See: Description

- Class Summary
  Class | Description
  --- | ---
  DriverAdapterCPDS | An adapter for JDBC drivers that do not include an implementation of `ConnectionPoolDataSource`, but still include a `DriverManager` implementation.
  PStmtKeyCPDS | A key uniquely identifying a `PreparedStatement`.

## Package org.apache.commons.dbcp2.cpdsadapter Description

This package contains one public class which is a `ConnectionPoolDataSource` (CPDS) implementation that can be used to adapt older `Driver` based JDBC implementations. Below is an example of setting up the CPDS to be available via JNDI in the catalina servlet container.

In server.xml, the following would be added to the <Context> for your webapp:

      <Resource name="jdbc/bookstoreCPDS" auth="Container"
                 type="org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS"/>
       <ResourceParams name="jdbc/bookstoreCPDS">
         <parameter>
           <name>factory</name>
           <value>org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS</value>
         </parameter>
             <parameter><name>user</name><value>root</value></parameter>
             <parameter><name>password</name><value></value></parameter>
             <parameter>
                 <name>driver</name>
                 <value>org.gjt.mm.mysql.Driver</value></parameter>
             <parameter>
                  <name>url</name>
                  <value>jdbc:mysql://localhost:3306/bookstore</value>
             </parameter>
       </ResourceParams>

In web.xml. Note that elements must be given in the order of the dtd described in the servlet specification:

     <resource-ref>
       <description>
         Resource reference to a factory for java.sql.Connection
         instances that may be used for talking to a particular
         database that is configured in the server.xml file.
       </description>
       <res-ref-name>
         jdbc/bookstoreCPDS
       </res-ref-name>
       <res-type>
         org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS
       </res-type>
       <res-auth>
         Container
       </res-auth>
     </resource-ref>

Catalina deploys all objects configured similarly to above within the java:comp/env namespace.

Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.