Metawerx Java Hosting Small Logo

DBCP - Database Connection Pool

Commons DBCP is a project by the Apache Software Foundation, which provides a database connection pool facility for a Java application.

Each time an application communicates with a database, a connection is required.

Opening and closing connections is time consuming.

A connection pool stores/caches connections, allowing them to be re-used by the application on demand. This increases performance dramatically in most cases.

The connection pool layer is separated from the JDBC driver and the application, providing an invisible layer between them.

Common Topics:

  • Maximum Active Connections - the maximum number of concurrent connections the pool should allow. After this limit, the pool will wait for a connection to become available before providing it to the caller. Too many concurrent connections to the database can decrease performance, so it is important to find an appropriate balance. Unless an application is extremely busy, 2-5 connections is usually plenty.
  • Max Idle Connections - the maximum number of idle connections that should be kept active. For example, if 5 connections are opened at the same time, then closed again, all 5 connections would normally remain in the pool until the application needs them again. If the Max Idle Connections setting is set to 2, then only 2 will be kept active, the other 3 will be closed until. When multiple applications connect to the same database server, this decreases the total number of connections to the database until they are needed.
  • Connection Leak - a situation which occurs when a connection is opened, then forgotten about. This is known as a "leak", because each time it happens, one less connection is available for re-use.

More Information

navigation
metawerx specific
search
Share
tools
help

referring pages

Share