Comparison between Tomcat JDBC connection pool and Apache Commons DBCP connection pool

Difference between Tomcat JDBC connection pool (org.apache.tomcat.jdbc.pool) and Apache Commons DBCP connection pool

 1.Commons DBCP 1.x is single-threaded. All connection pools are locked when an object is allocated or returned. (Not available for Commons DBCP 2.x)

  2. The performance of Commons DBCP 1.x may become very slow when the number of logical CPUs increases or the number of concurrent counties increases. The impact on high concurrency systems will be more pronounced (not applicable to Commons DBCP 2.x)

   3.Commons DBCP has more than 60 classes. The core of tomcat-jdbc-pool has only 8 classes, and if the requirements change in the future, the tomcat JDBC connection pool will change less.

   4. Commons DBCP uses a static interface, and the corresponding jre needs the corresponding DBCP version, otherwise NoSuchMethodException will be thrown

    5. The Tomcat JDBC connection pool can obtain asynchronous connections without adding additional threads to the library itself.

    6. The Tomcat JDBC connection pool uses the javax.sql.PooledConnection interface to obtain the underlying connection

    7. Tomcat JDBC connection pool can prevent starvation. If the pool becomes empty, the thread will wait for a connection. When the connection returns, the pool will wake up the correct waiting thread.

         


Tomcat JDBC connection pool Features;

1. Support high concurrency environment and multi-core /CPU system.
2. Dynamic implementation of the interface. Support java.sql and java.sql interface (as long as JDBC driver), even when compiled with lower version of JDK . 3. Validation interval. We don't have to verify every time we use a single connection, we can verify it when we lend or return a connection, as long as it doesn't fall below the interval we set. 4. Execute the query only once. A configurable query that is executed only once when a connection to the database is established. This feature is useful for session setup, as you may want to keep the session open for the entire time the connection is established. 5. Ability to configure custom interceptors. Enhance functionality with custom interceptors. Interceptors can be used to collect query statistics, cache session state , reconnect previously failed connections, re-queries, cache query results, etc. Due to the large number of options available, this custom interceptor is also unlimited and has nothing to do with the JDK version of the java.sql / javax.sql interface . 6. High performance. 7.








It's simple to implement, with very few lines of code and source files, thanks to simplicity being
a . Compared with
c3p0 , its source files exceed 200 (the latest statistics), while the Tomcat JDBC core has only 8
files, and the connection pool itself is only about half of this number, so it is easy to track and modify possible bugs .
8. Asynchronous connection acquisition. Connection requests can be queued and the system returns a Future<Connection> .
9. Better handling of idle connections. Instead of simply and rudely closing the idle connection directly, the connection is still kept in the pool, and
the size of the idle connection pool is controlled through a more ingenious algorithm.
10. You can control the time when the connection should be discarded: when the pool is full, it will be discarded, or a pool usage tolerance value can be specified, and
the .
11. Reset the discarded connection timer by query or statement. Allows a connection that has been in use for a long time to not be discarded due to a timeout. This is
achieved by using
ResetAbandonedTimer .
12. After the specified time, close the connection. Similar to the time to return to the pool.
13. When the connection is about to be released, get JMXNotify and record all logs. It is similar to removeAbandonedTimeout , but
requires no action other than reporting information. This is achieved through the
suspectTimeout property.
14. The connection can be obtained through java.sql.Driver , javax.sql.DataSource or javax.sql.XADataSource .
This is achieved through the dataSource and dataSourceJNDI properties.
15. Support XA connection.

        ------- Please indicate the source 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325389189&siteId=291194637