I currently am doing some basic connection pooling.  I don't do any direct
database calls in my JSPs, but my JSPs use beans that use the connection
pooling.  Currently in my java classes I have code like:

      String sql = "SELECT * FROM PRODUCT WHERE STORE_NO = " + storeNo;
      DBConnectionManager connMgr = DBConnectionManager.getInstance();
      Connection con = connMgr.getConnection("designerpool");
      try{
        Statement stmt = con.createStatement();
        try{
          ResultSet rs = stmt.executeQuery(sql);
          try{
...
     }finally{
        connMgr.freeConnection("designerpool", con);
      }


This approach obviously doesn't give me application wide connection pooling.
I understand that I can create a servlet that initializes when JRun starts
and get the reference to the DBConnectionManager for app wide connection
pooling.  I'm not quite sure how to do this.  I would write a servlet (or
JSP) that creates an instance of DBconnMgr and add it to the application
context and setup JRun to preload it (not sure how to make it application
wide inside a servlet, don't know how to set up JRun to preload).  Then I
guess I have to get the reference to the DBConnectionManager from my JSP and
pass it as a property to all my beans that need database access, right?  Or
is there a way that I could have the beans gain access in another way,
inside the bean itself - this would be cleaner than passing the refernece
all over the place...it would be nice to have a static
DBConnectionManager.getAppInstance that calls the preloaded servlet and gets
the application wide DBConnectionManager instance.

Can someone help me out??

Thanks,
Phil
[EMAIL PROTECTED]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to