A JDBC Connection Pooling Concept

Ads

In this tutorial you will learn JDBC connection pooling concept and how to make pool of connection object.

JDBC Connection Pooling

JDBC Connection pooling is similar to any other object pooling. Connection
pooling is very useful for any application which uses database database as
backend. Database connection is very expensive to create over network, for this
we need to create a network connection, then initializing a database, creating a
session, doing transaction and then after closing the connection, this take more
time, therefore application becomes slower. The valuable database resources such
as memory, cursors, locks , temporary tables all tends to increase on numbers of
concurrent connections.

In connection pooling, we creates limited numbers of connection objects pools
at a time, such as 10 connections, 50 connections, 100 connections etc. This
depends upon the capacity of the database that how much connections it can
handle at a time. If any request comes we allocate a connection object to it.
When it completed their work then it releases the connection object and this
object is added into the pool.

An example of JDBC connection pooling is given below. to run this example you
need to create a database in MySql named 'student'.