Home » Java » Connection pooling options with JDBC: DBCP vs C3P0

Connection pooling options with JDBC: DBCP vs C3P0

Posted by: admin November 2, 2017 Leave a comment


What is the best connection pooling library available for Java/JDBC?

I’m considering the 2 main candidates (free / open-source):

I’ve read a lot about them in blogs and other forums but could not reach a decision.

Are there any relevant alternatives to these two?


DBCP is out of date and not production grade. Some time back we conducted an in-house analysis of the two, creating a test fixture which generated load and concurrency against the two to assess their suitability under real life conditions.

DBCP consistently generated exceptions into our test application and struggled to reach levels of performance which C3P0 was more than capable of handling without any exceptions.

C3P0 also robustly handled DB disconnects and transparent reconnects on resume whereas DBCP never recovered connections if the link was taken out from beneath it. Worse still DBCP was returning Connection objects to the application for which the underlying transport had broken.

Since then we have used C3P0 in 4 major heavy-load consumer web apps and have never looked back.

UPDATE: It turns out that after many years of sitting on a shelf, the Apache Commons folk have taken DBCP out of dormancy and it is now, once again, an actively developed project. Thus my original post may be out of date.

That being said, I haven’t yet experienced this new upgraded library’s performance, nor heard of it being de-facto in any recent app framework, yet.


I invite you to try out BoneCP — it’s free, open source, and faster than the available alternatives (see benchmark section).

Disclaimer: I’m the author so you could say I’m biased 🙂


UPDATE: As of March 2010, still around 35% faster than the new rewritten Apache DBCP (“tomcat jdbc”) pool. See dynamic benchmark link in benchmark section.

Update #2: (Dec ’13) After 4 years at the top, there’s now a much faster competitor : https://github.com/brettwooldridge/HikariCP

Update #3: (Sep ’14) Please consider BoneCP to be deprecated at this point, recommend switching to HikariCP.

Update #4: (April ’15) — I no longer own the domain jolbox.com, but the new owner has kept the old content so beware.


I was having trouble with DBCP when the connections times out so I trialled c3p0. I was going to release this to production but then started performance testing. I found that c3p0 performed terribly. I couldn’t configure it to perform well at all. I found it twice as slow as DBCP.

I then tried the Tomcat connection pooling.

This was twice as fast as c3p0 and fixed other issues I was having with DBCP. I spent a lot of time investigating and testing the 3 pools. My advice if you are deploying to Tomcat is to use the new Tomcat JDBC pool.


For the auto-reconnect issue with DBCP, has any tried using the following 2 configuration parameters?

validationQuery="Some Query"



Have been using DBCP for a couple of years now in production. It is stable, survives DB server reboot. Just configure it properly. It only requires a handful of parameters to be specified so don’t be lazy. Here is a snippet from our system production code which lists parameters that we explicitly set to make it work:

DriverAdapterCPDS driverAdapterCPDS = new DriverAdapterCPDS();


SharedPoolDataSource poolDataSource = new SharedPoolDataSource();
poolDataSource.setValidationQuery("SELECT 0");


Here are some articles that show that DBCP has significantly higher performance than C3P0 or Proxool. Also in my own experience c3p0 does have some nice features, like prepared statement pooling and is more configurable than DBCP, but DBCP is plainly faster in any environment I have used it in.

Difference between dbcp and c3p0? Absolutely nothing! (A Sakai developers blog)

See also the like to the JavaTech article “Connection Pool Showdown” in the comments on the blog post.


Another alternative, Proxool, is mentioned in this article.

You might be able to find out why Hibernate bundles c3p0 for its default connection pool implementation?


Unfortunately they are all out of date. DBCP has been updated a bit recently, the other two are 2-3 years old, with many outstanding bugs.


Dbcp is production ready if configured properly.

It is for example used on a commerce Website of 350000 visitors/ day and with pools of 200 connections.

It handles very well timeouts provided you configure it correctly.

Version 2 is on progress and it has a background which makes it reliable since Many
Production problems have been tackled.

We use it for our batch server solution and it has been running hundreds of batches That work on millions of lines in database.

Performance tests run by tomcat jdbc pool show it has better performance than cp30.


Another alternative is HikariCP.

Here is the comparison benchmark


Just got done wasting a day and a half with DBCP. Even though I’m using the latest DBCP release, I ran into exactly the same problems as j pimmel did. I would not recommend DBCP at all, especially it’s knack of throwing connections out of the pool when the DB goes away, its inability to reconnect when the DB comes back and its inability to dynamically add connection objects back into the pool (it hangs forever on a post JDBCconnect I/O socket read)

I’m switching over to C3P0 now. I’ve used that in previous projects and it worked and performed like a charm.


c3p0 is good when we are using mutithreading projects. In our projects we used simultaneously multiple thread executions by using DBCP, then we got connection timeout if we used more thread executions. So we went with c3p0 configuration.


A good alternative which is easy to use is DBPool.

“A Java-based database connection pooling utility, supporting time-based expiry, statement caching, connection validation, and easy configuration using a pool manager.”