Alex Rivera | Logout

tomcat-dbcp vs commons-dbcp

Asked 2011-01-17T10:08:17.657
73

It seems there is a lot of confusion between these two connection pooling libraries. What I want to know is which one is better (if at all)?

Here are some points which I would like to put up... Could someone please verify?

  1. Tomcat DBCP: uses the default tomcat-dbcp.jar which will be present in your tomcat/lib directory. You do not need commons-dbcp.jar or commons-pool.jar libraries in your web-inf/lib. The DB driver should be placed in tomcat/lib.

  2. Tomcat DBCP datasource class is org.apache.tomcat.dbcp.dbcp.BasicDataSource. Commons DBCP datasource class is org.apache.commons.dbcp.BasicDataSource.

  3. The only difference between these two can be found in this blog. Do not know if the information is correct or not.

  4. The official Tomcat documentation mentions clearly that most classes have just been re-named and re-packaged.

So the question is: which one to use and which one is better?

Edit
Report

1 Answer

11

Older versions of Apache Commons DBCP (i.e. version 1.2) had some nasty thread-safety issues under high load conditions, making it unsuitable for that kind of usage. It doesn't surprise me that the Tomcat folks re-worked it to fix these issues.

However, my understanding is that Commons DBCP 1.4 fixes these issues. I can't confirm that personally, but it may render the Tomcat version redundant.

Interestingly, SpringSource also rewrote Commons DBCP for their repackaged version of Tomcat (tc-Server), and they claim big performance benefits from it. They haven't open-sourced that, though.

answered 2011-01-17T10:55:21.893

Your Answer