Tomcat Connection Pool Optimization

Tomcat Connection Pool LogoTomcat JDBC Connection Pool Tuning

In Tomcat 7, the default connection pool provider is DBCP.  The Tomcat authors obviously realized that this pooling implementation wasn’t ready for prime time, so they created their own implementation.  The team at Apache has done a very thorough job of outlining all the shortcomings of DBCP along with the features of their new implementation.

As of this writing, both Tomcat 7 and Tomcat 8 use the DBCP Connection Pool by default when you declare a Datasource as a <Resource/> in your context.xml.  Perhaps one day the production ready implementation will be the default.  Until then, frustrated DevOps Engineers will find this article useful and necessary.

Using the Tomcat Connection Pool

Follow the instructions in the resource link to take full advantage of the high performance Tomcat Connection Pool.  Depending on your database, certain parameters will have more positive tuning effects than others.  The key to removing the DBCP Pool and using the Tomcat Connection Pool is the factory parameter.

Here is a starter example for an Oracle database.

1
2
3
4
5
6
7
8
9
<Resource
    name="jdbc/myDataSource"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    url="jdbc:oracle:thin:@oracle.domain.com:1521:SID"
    username="scott"
    password="tiger" />

Support Request

If you would like assistance with setting up or configuring your Java Application Container’s Connection Pool and DataSource, please Contact Prowave for a free consultation.  For emergency support, please call 904-302-7734.

Resources

The Tomcat JDBC Connection Pool

Posted by: Prowave Team

Leave A Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.