• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Connection Pool ,public it or private it?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
{ ........
 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic