This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes How to use Connection Pooling? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to use Connection Pooling?" Watch "How to use Connection Pooling?" New topic

How to use Connection Pooling?

Girish Bapat

Joined: Jan 06, 2005
Posts: 2
I am opening and closing connection for my each method in database bean.
I have 2 questions
Does this practice create performance problem?
If yes
Can someone tell me how to use connection pooling
Thanks in Advance,
- Girish
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You should always close a connection as soon as your are finished with it - ignoring performance implications. And you should do the same even if you use connection pooling (though in this instance the connection is actually returned to the pool rather than closed).

Your code shouldn't change if you use connection pooling or not (assuming you are using a DataSource). Where are you getting your connection pooling implementation from?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

How you implement one depends on what JDBC driver you are using. Some have it built in. What container you are using. Tomcat (and most other) containers has a container managed connection pool. You can also implement one yourself.
There is good opensource implimentation here:

Check the documentation for your driver and servlet container.
If you followed Paul's advice, you may already be using it.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Your question is off topic for this forum.

This forum is for Servlets questions.

I am going to move this thread to the more appropriate, JDBC forum

Thanks and good luck


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: How to use Connection Pooling?
It's not a secret anymore!