This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
We are happy to announce the release 0.8.3 of Vibur DBCP.
Vibur DBCP is a concurrent, fast and fully-featured JDBC connection pool based on Java dynamic proxies. It has concise, easy to understand and maintain
source code, and modular design which includes a separate and dedicated object pool.
It is released under Apache License 2.0.
Most important features and characteristics:
Built using standard Java concurrency utilities and dynamic proxies, does not use any synchronized
blocks/methods during normal pool operations.
Supports fairness parameter, which when set to true, guarantees that threads invoking the pool's
take methods will be selected to obtain a connection from it in FIFO order, and no thread is
starved out from accessing the pool's underlying resources.
The only external dependencies for Vibur DBCP are its dedicated object pool, slf4j/log4j,
and ConcurrentLinkedHashMap. The CLHM dependency can be excluded if the JDBC Statement caching
is not needed.
SQL queries logging and getConnection() calls logging if their execution time is
longer than a given limit.
Caching support for JDBC Statements (Prepared and Callable).
I've tried to build a list of the most important features and characteristics of Vibur DBCP, Apache Commons DBCP and C3P0, and to objectively compare them to the best of my knowledge. I'm eagerly looking to get feedback on Vibur DBCP and I'm encouraging everyone who can afford to invest some time to give it a try and to come back to me if he/she has any questions, issues, etc.
Source code size:
Having as simple as possible design and concise and easy to maintain source code was one of the main objectives of Vibur DBCP. Currently it has approximately 30 source files and about 3.2K SLOC.
Apache Commons DBCP includes over 75 source files and C3P0 has over 90 source files. Both of them have considerably larger SLOC count than Vibur DBCP.
Built on top of a separate and dedicated object pool project:
Apache Commons DBCP is built on top of Apache Commons Pool.
For C3P0 the object pooling implementation is part of the C3P0 source code.
Built using standard Java concurrency utilities:
Vibur DBCP does not use any synchronized blocks/methods during normal pool operation. At low level, it is built on top of a ConcurrentLinkedQueue which is guarded by a Semaphore, and it is also utilizing a ConcurrentHashMap for object validation purposes.
Both Apache Commons DBCP and C3P0 make heavy use of synchronized blocks/methods as part of their pools' operations.
Support for fairness parameter which guarantees that no thread will be starved out from accessing the pool's resources:
Apache Commons DBCP provides such support via a custom implementation in Apache Commons Pool.
C3P0 - seems there is no support.
Built-in support for slow SQL queries logging and long getConnection() calls logging:
Vibur DBCP provides support for both of these.
Apache Commons DBCP and C3P0 - seems there is no support.
Caching support for JDBC Statements (Prepared and Callable):
Implemented in one or another way by all pools.
Hibernate 3.x and 4.x integration support:
Vibur DBCP has built-in support for Hibernate 3.x, and support for Hibernate 4.x will be added in the next version which should be available in a week or so.
Apache Commons DBCP does not have built-in support for Hibernate, however a class providing integration for Hibernate 3.x is publicly available.
C3P0 has integration for Hibernate 3.x and 4.x as part of the Hibernate distributions.
JDBC Connection validation:
Vibur DBCP validates the JDBC connections on take if they have been idle for longer than a configured time, and implements this via call to the standard Connection.isValid() method or via executing a configured custom query. Note that validating the connections only once for a period of time instead of on every take from the pool may save a large number of unnecessary calls to the database.
Both Apache Commons DBCP and C3P0 can validate the JDBC connections on take, restore or while idle via executing a configured custom query.
Eviction of idle JDBC Connections:
Vibur DBCP supports this via configuring reducerTimeIntervalInSeconds and reducerSamples.
Apache Commons DBCP supports this via configuring timeBetweenEvictionRunsMillis, numTestsPerEvictionRun and minEvictableIdleTimeMillis.
C3P0 supports this via configuring maxConnectionAge, maxIdleTime and maxIdleTimeExcessConnections.
Access to the raw underlying JDBC Connection:
Implemented in one or another way by all pools.
Ability to provide records (including stack traces) for all currently taken (unreturned) JDBC connections: