File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes What is Connection Pooling? And how to use It Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "What is Connection Pooling? And how to use It" Watch "What is Connection Pooling? And how to use It" New topic

What is Connection Pooling? And how to use It

Ahmed Shaikh
Ranch Hand

Joined: Jul 25, 2005
Posts: 51
Hi All.
plz any one tell me some thing about connection Pooling.
please explain me with example..
waiting for reply.
Thanx in advance
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

This page
should answer your questions.

By the way: This is the library used by Tomcat for connection pooling.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Some operations are verrrryyyy slow. Database connections are the usual culprit. Consider an application where you have a buch of short database operation scattered through your application, like 'check user exists', 'get user groups', 'load preferences', 'update list of things', 'check other list for updates' and about a hundred more.

You would find that the cost of opening and closing database connections took significantly more time than the actual operations. You may consider solutions like using a single connection in yourr application, or maintaining a connection for a user, but these solutions, while sounding useful, have serious problems of their own.

The solution is to get an intermediate layer to open a bunch of connections and share them with anyone who wants to use them. Database connections are nice since you can almost always reuse them. Connection Pools, a specific type of Resource Broker, can also manage a bunch of other things under the covers for you so you don't have to worry about them.

But enough about Connection Pooling in the servlets forum, I'll move this thread to the JDBC forum for you.

Rajendra Pachouri

Joined: Sep 16, 2005
Posts: 10
JDBC connection pooling related with the performace of server and your webapplication that why we use the connection pooling .
Actualy in connection pooling we gave connecton to database with server and to application we gave refrence of server . So same connection can be give in no.of application so performace increase.

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 439
David have explained it very well.

My friends and I have a connection pooling class of our beloved teacher mr. waheed from our java learning days that we love to use.
I can post it if I am allowed.


Maki Jav

Help gets you when you need it!
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

In general, the question of posting other people's code depends on two criteria:
1) Did you give them credit? - This you already did.
2) Is the other person ok with it? - Not sure if how the original author would feel on this one.

In any case, the Conmmon's link Ben provided is very good. I highly recommend that over a custom implementation.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: What is Connection Pooling? And how to use It
It's not a secret anymore!