What is the state-of-the-art in JDBC connection pool libraries?

Years ago the Tomcat JDBC Connection Pool library was developed as an alternative for highly-threaded environments because of weaknesses in the Apache Commons DBCP. Now I see that a new version (DBCP2) has been built using a new version 2 of Apache Commons Pool, another library specially built to support implementing various object-pooling projects.

There are some other libraries, but I don't know their current state:

Please give pros and cons of the various choices for use in a highly-threaded Java Servlet environment with relational databases such as Postgres or H2 Database Engine.

My own priorities are:

  • Proper JDBC behavior
  • Reliability (robust in a highly-threaded environment)
  • Easy to install & manage
  • Simple, minimal tuning required for general usage

Hyper-speed, such a being good at benchmark testing, is not important. Tolerating rapid turnover of briefly-used connections in likely contention within a highly-threaded environment is my only performance concern.

JMX or other runtime-management/supervision access is a bonus.

I'm currently using the Tomcat JDBC Connection Pool with Tomcat 8 and Postgres on Java 8 with no problems. I'm just wondering if that is still the best option. The reviews I’ve found by googling seem to be quite a few years old. I am not using Hibernate or any other object-relational mapper (ORM) nor JPA technology; I just hand-write SQL code in JDBC.

What is a good JDBC connection pool library for my needs?

  • What did decide to go with? And how did you make your decision? – Jeevan Patil Jul 14 '17 at 5:39
  • 1
    @JeevanPatil웃 Long story short, do not necessarily use connection pooling. Building a pool properly is surprisingly difficult. Even if done right, you can have problems such as a transaction left pending in a connection you just got from pool. If getting a connection to a DB server on same machine, performance is quite fast and does not justify using a pool in knee-jerk fashion without further consideration. Use simple direct connections without a pool until you know you have a demonstrable performance issue. If you hold a connection for extended use, even less need for pool. – Basil Bourque Jul 14 '17 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.