File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Connection Pool ,public it or private it? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Connection Pool ,public it or private it?" Watch "Connection Pool ,public it or private it?" New topic
Author

Connection Pool ,public it or private it?

Tazzmission
Greenhorn

Joined: Jan 16, 2002
Posts: 20
I have downloaded a connection pool java in coreservlet, in servlets, I should declare it as public or private? Thanks
public class ServletOne extends HttpServlet
{
private ConnectionPool connectionPool;

public void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, java.io.IOException
{ ........
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
I don't make instance variables public -- I use getter/setter (JavaBean style) methods if it's necessary to share objects. Or, I might store a reference to an object in the servlet context or session, depending on what seems appropriate.
I view connection pooling as an application resource, not limited to or associated with a user session. So if I have other classes in a web app that will need connections from the pool, I store a reference to it in a servlet context or a JNDI context where other classes can easily get to it.
I managed to stray pretty far from your public/private question, but I hope it helped.


Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Tazzmission",
You now have 20 posts with an invalid display name.
Accounts with invalid display names get deleted
Please read the the JavaRanch Naming Policy http://www.javaranch.com/name.jsp and edit your profile so that your display name is valid.
Do it soon.
Thanks,
Dave.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Connection Pool ,public it or private it?
 
Similar Threads
LAST_INSERT_ID() with threads
sl314.util.sql.ConnectionPool
Running servlet from bean
question about static variable...
What is Connection pool?