Google

Tuesday, January 20, 2009

Database Connection Pooling

Database connection pool is a collection/group of identical JDBC connections to a database. These connections are created when the connection pool is build or as and when a connection is required.

The applications usually interact with some form of database and getting a connection from the application to fetch/update the data in the database, require some time which is unacceptable if we create a new connection each time we need to interact with the database.

The idea is that you create some connections and put in some form of pool from where the application can pick a connection when required. Since, the time taken to make a database call is usually quite small, the application can use the connection and return it back to the pool. This makes sure that at any given point of time, you would not need more than n number of connections.

Advantages of using connection pool:
1. As mentioned above, it is more efficient to obtain a connection from the pool rather than creating a new one whenever the application needs to talk to the database.

2. Connection pool provides a form of abstraction such that the application does not need to know the details of how to create a connection and details such as username/password etc.

3. The above mentioned abstraction also provides the flexibility to change the underlying database without any changes in the application code.

4. Using the connection pool ensures that you do not have a lot of connections open at the same time. This is possible because the connections can be reused by the application components.

Labels: , ,

0 Comments:

Post a Comment

<< Home