Connection Pool overview

What is connection Pool ?

Connection pooling is the technique used to increase the performance of the application when an application makes a multiple connection requests.

Connection pooling takes care of managing connections(prepare,open and close)

How connection pool works ?

Connection Pool API is responsible for opening N connections and leave them ready for our application.

Our application will just ask for the pool to get a new connection, it will use it and then deliver it back to the Pool.

If a connection is stale, the pooling mechanism would then close it and re-open a new one.

This way we can use the connections in a more better way, as we no need to wait for the connection to be established during the actual execution of our code and we don’t have to worry about stale connections


Why we need to use Connection pool ?

We know that, opening a database connection is an expensive operation, so pooling keeps the connections active.

When a connection is requested by an application, one of the active connection is given to the application rather than opening new one.

This will increase the performance drastically when there are multiple requests to the database in our application.

Connection Pool in Hibernate

Hibernate has provided a default connection pooling mechanism but it is not that much scalable to use in production.

So most of the applications uses the third party connection pool providers for better performance.

Some of the third party connection pool providers are DBCP,C3P0, BoneCP and Proxool etc.

Most widely used connection pool provider is c3p0.

Hibernate automatically identifies which connection pool provider to use based on the properties configured in the config file.

However we can define the connection provider with the < hibernate.connection.provider_class > property as below in the config file

  1. //Config property for specifying connection pool
  2. <property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property >
//Config property for specifying connection pool
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property >

Note :If we do not configure a connection pool, the default is used.

About the Author

Founder of
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to

Connect with me on Facebook for more updates

Share this article on