This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Servlet and Connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet and Connection pooling" Watch "Servlet and Connection pooling" New topic
Author

Servlet and Connection pooling

ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 130
Hi,
I am using Connection pooling and storing the pool in servlet context and I have question about getting the connection from servlet context in a all servlets,
I want to code a single class where the input paramter will be servlet context and session and this class will return me the connection depending upon some parameter in session.
I want to keep it is one class so i can change my implementation in future and change only one class and my servlets will not be affected
So any suggestions on doing this, one that i think that this class must have a static method which is synchronised so i dont have to create instance of this class in each servlet ,will synchronise slow the performance, what about using singleton pattern(any code of singleton pattern)
Any suggestions...


A$HI$H
David Carew
Greenhorn

Joined: Jul 08, 2002
Posts: 5
See the Service Locator pattern:
Java BluePrints
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet and Connection pooling