File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to use Connection Pooling?" Watch "How to use Connection Pooling?" New topic
Author

How to use Connection Pooling?

Girish Bapat
Greenhorn

Joined: Jan 06, 2005
Posts: 2
Hello,
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
Bartender

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
Sheriff

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:
http://jakarta.apache.org/commons/dbcp/

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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: How to use Connection Pooling?
 
Similar Threads
connection with database
connection pooling
connection pooling in Struts
Connection Pooling
Driver Loading