File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat JDBC Connection Pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat JDBC Connection Pool" Watch "Tomcat JDBC Connection Pool" New topic

Tomcat JDBC Connection Pool

K Mansoor
Ranch Hand

Joined: Jan 10, 2006
Posts: 52
Tomcat has introduced a Connection Pool lately, I think from version 7.25.

Is there a way to use this pool with earlier versions? i wonder if a separate jar could be downloaded. The problem is most hosting sites are not using the latest versions.
Tim Moores

Joined: Sep 21, 2011
Posts: 2413
Not sure what this new pool is supposed to do differently, but if you were using Tomcat's built-in DataSource, you would/could have been using connection pooling for years. And if you weren't using that, you could have used Apache DBCP in your web app, and achieved pretty much the same result.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Can you provide us with a link about this?

Tomcat has supported plugin connection pooling for probably a decade now. As shipped, there's a copy of the Apache DBCP pooler pre-supplied, but anyone that wants to can use alternate poolers as well. For a while, there was in fact a serious competitor to DBCP, although most people use DBCP now.

An IDE is no substitute for an Intelligent Developer.
K Mansoor
Ranch Hand

Joined: Jan 10, 2006
Posts: 52
Tomcat 7.26 (JDBC Pool)

The JDBC Connection Pool org.apache.tomcat.jdbc.pool is a replacement or an alternative to the commons-dbcp connection pool.

So why do we need a new connection pool?

Here are a few of the reasons:

commons-dbcp is single threaded, in order to be thread safe commons-dbcp locks the entire pool, even during query validation.
commons-dbcp is slow - as the number of logical CPUs grow, the performance suffers, the above point shows that there is not support for high concurrency Even with the enormous optimizations of the synchronized statement in Java 6, commons-dbcp still suffers in speed and concurrency.
commons-dbcp is complex, over 60 classes. tomcat-jdbc-pool, core is 8 classes, hence modifications for future requirement will require much less changes. This is all you need to run the connection pool itself, the rest is gravy.
commons-dbcp uses static interfaces. This means you can't compile it with JDK 1.6, or if you run on JDK 1.6/1.7 you will get NoSuchMethodException for all the methods not implemented, even if the driver supports it.
The commons-dbcp has become fairly stagnant. Sparse updates, releases, and new feature support.
It's not worth rewriting over 60 classes, when something as a connection pool can be accomplished with as a much simpler implementation.
Tomcat jdbc pool implements a fairness option not available in commons-dbcp and still performs faster than commons-dbcp
Tomcat jdbc pool implements the ability retrieve a connection asynchronously, without adding additional threads to the library itself
Tomcat jdbc pool is a Tomcat module, it depends on Tomcat JULI, a simplified logging framework used in Tomcat.
Retrieve the underlying connection using the javax.sql.PooledConnection interface.
Starvation proof. If a pool is empty, and threads are waiting for a connection, when a connection is returned, the pool will awake the correct thread waiting. Most pools will simply starve.
I agree. Here's the link:
subject: Tomcat JDBC Connection Pool
It's not a secret anymore!