Connection pooling options with JDBC: DBCP vs C3P0

前端 未结 16 1849
遥遥无期
遥遥无期 2020-11-22 06:17

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

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

  • Apache DBCP - http:/
相关标签:
16条回答
  • 2020-11-22 06:54

    We came across a situation where we needed to introduce connection pool and we had 4 options in front of us.

    • DBCP2
    • C3P0
    • Tomcat JDBC
    • HikariCP

    We carried out some tests and comparison based on our criteria and decided to go for HikariCP. Read this article which explains why we chose HikariCP.

    0 讨论(0)
  • 2020-11-22 06:56

    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.

    0 讨论(0)
  • 2020-11-22 06:56

    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?

    0 讨论(0)
  • 2020-11-22 06:56

    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."

    http://www.snaq.net/java/DBPool/

    0 讨论(0)
  • 2020-11-22 07:01

    Another alternative is HikariCP.

    Here is the comparison benchmark

    0 讨论(0)
  • 2020-11-22 07:06

    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.

    0 讨论(0)
提交回复
热议问题