tomcat-dbcp vs commons-dbcp

后端 未结 6 1129
耶瑟儿~
耶瑟儿~ 2020-12-02 06:05

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 whi

6条回答
  •  借酒劲吻你
    2020-12-02 06:34

    Tomcat DBCP is just a renamed version of Apache Commons DBCP, with also a different internal package name prefix.

    At build time, Tomcat fetches the Commons DBCP sources (the version depends on the Tomcat version, for instance Tomcat 7.0.27 uses Commons DBCP 1.4), and does package name replacement (org.apache.commons -> org.apache.tomcat.dbcp) and builds the result as tomcat-dbcp.jar.

    This is done so that the internal Tomcat JDBC pools never conflict with possible application uses of the Commons DBCP classes. This avoids many potential classloading issues.

    Edit: The "dbcp" packages are about datasource management. For the pure pool implementation, Commons DBCP depends on Commons Pool (package org.apache.commons.pool), but in Tomcat the implementation of the pool is replaced with Tomcat's own JDBC pool (package org.apache.tomcat.jdbc.pool).

提交回复
热议问题