This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: converted to 1.6 markup

DBCP Overview

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="cb79bfda-ece3-43e6-9430-afa524a47720"><ac:plain-text-body><![CDATA[ {{

[ }}

Commons-DBCP] provides database connection pooling services.[BR]
A lot of information is available on the [ DBCP website]. If you don't find the information you need you can always contact us using one of the [ mailing lists].


Release Plans

External Resources

Here's a little diagram showing what datastructure DBCP sets up and how that datastructure is used in case the DriverManager is employed to obtain Drivers at runtime. Please send any corrections (for now) to

Diagrams hosted by


Security Manager settings

Wiki MarkupIf you're running tomcat with the \[ Security Manager\], you will need to add to your catalina.policy:

No Format
grant {
        permission java.lang.RuntimePermission "*";


Tomcat 5.0 Configuration examples

Wiki MarkupSome Tomcat JNDI Datasource examples (in addition to the \[ Tomcat 5.5 JNDI datasource howto\]).


No Format
<Resource name="jdbc/abandoned" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/abandoned">


2: Saying what class will actually create instances of the above, i.e. give the factory. This is actually not necessary if you want 'org.apache.commons.dbcp.BasicDataSourceFactory' as that is the default factory used by Tomcat whenever 'javax.sql.DataSource' objects should be created. By setting 'factory', you can override that default value. 'o.a.c.d.BasicDataSourceFactory' creates 'org.apache.commons.dbcp.BasicDataSource' instances. These use a resource pool of type 'org.apache.commons.pool.impl.GenericObjectPool'. And for this type of pool we can demand that objects be verified at borrowing time - which is what we want as it will prevent Tomcat getting its paws on stale database connections.

Wiki Markup*3*: Configuring the attributes of the 'BasicDataSourceFactory'. The allowed attributes can be found by looking for JavaBean-compliant set() methods and members in the source or the \[ DBCP API doc\]. In particular: what driver shall be used by the factory to actually get database connections: 'com.mysql.jdbc.Driver'.

Additionally (and one level down, if you will) the 'Driver' named in '!driverClassName' is itself configured through the URL used when a new connection is created

I have put the 'Resource' element into the 'GlobalNamingResource' element instead of the 'Context' element. If you want to put it in the 'Context' element, the 'Realm' must be in the same 'Context' element and must additionally have the attribute 'localDataSource' set to 'true'.

No Format
<Server ...>


        <Resource name="jdbc/mydatabase"
                  validationQuery="SELECT 1"


    ...something something...



The Realm implementation is 'org.apache.catalina.realm.DataSourceRealm'; it will use a 'javax.sql.DataSource' interface found in the JNDI initial context. The location of that interface inside the JNDI namespace is given by 'dataSourceName': 'java:com/env/jdbc/mydatabase'.

No Format
<Host ....>

  <Context ...> ... </Context>
  <Context ...> ... </Context>

  <Realm className="org.apache.catalina.realm.DataSourceRealm"
                    userTable="account_t" />


Wiki MarkupFinally, beware \[ .cgi?id= 33357 bug 33357\] in 5.5.7 which should be fixed soon though :-P


Wiki Markup\[ Hibernate\] is a powerful, ultra-high performance object/relational persistence and query service for Java. Hibernate lets you develop persistent classes following common Java idiom - including association, inheritance, polymorphism, composition and the Java collections framework.


Q: Is this project still active or have they just not released anything in an excessive period of time?


The following links are of use for the discussion:

Q: What is "Validation of Connections"?


There is a 'autoReconnectForPools' starting from MySQL-Connector-J which I haven't looked into yet.

Wiki MarkupSee \[ Connector-J Connection Properties\] for additional details, and also the source for _com.mysql.jdbc.Connection.execSQL()_.