tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anand Prasad" <axpra...@hotmail.com>
Subject Re: Connection Pooling
Date Thu, 05 Oct 2000 00:21:55 GMT
Hi Steve,

Thanks a lot for your advice.

I cannot use servlet as it is shown in the example in javaexchange site.

Now based on your design, My Bean looks like this

public class DBBean{
    public static DbConnectionBroker db;

    //now I will have a method which get the connection

     public Connection getDbConnection(){
          DBBean.db.getConnection()
     }

     public void ReleaseDbConnection(Connection cn){
          DBBean.db.freeConnection(cn);
     }

}

//Could you please comment on this.  Is this the way you have written your 
bean.

Does the statis reference inside the bean will stay for entire lenght of the 
web server

>>When I instantiate the bean in the data layer I check to see if
>>that broker object exists if it doesn't I go ahead and instantiate >>it

Could you please comment on this.

do you create the scope as session or application.  If you check in first 
jsp page whether statis variable has been intialized or not, then does the 
same info exists in another jsp page.

<jsp:usebean Id="db" class=DBBean  scope=session/>
<jsp:usebean Id="db" class=DBBean  scope=application/>

I appreciate your response.

Thanks
--Anand





This is how I dealt with it.

I downloaded dbConnectionPool from
http://www.javaexchange.com/
Fabulous documentation here.

I created a bean with a static instance of their broker object.

When I instantiate the bean in the data layer I check to see if
that broker object exists if it doesn't I go ahead and instantiate it it.
In the bean I've got a method to get a connection from the pool and
to free the connection.

Works fabulously in production.

Steve








Shailendra Majmundar wrote:

>If you get this resolved, could you pl. keep me posted?
>
>Thanks
>
>-----Original Message-----
>From: Anand Prasad [mailto:axprasad@hotmail.com]
>Sent: Monday, October 02, 2000 5:35 PM
>To: tomcat-user@jakarta.apache.org
>Subject: Connection Pooling
>
>Hi All,
>
>I had posted this questions couple of days back.  I am using Apache with
>Jakarta.... Please Advice
>
>Here is the problem.  I have many JSP pages accessing the Database and I
>dont want to create and close connection in every page.
>
>I have written a connection pool to store the connection in a Hastable .
>
>Requirement:
>
>Now I need to load the connections once when the web server starts and have
>my Hastable loaded with connections.
>
> >From any JSP page if I can just call
>
><jsp:useBean id="cpool" scope="session"  class="ConnectionPool" />
>
><% Connection con = cpool.getConnection(); %>
>
>// Should provide me connection and then I will also have a method to
>release back the connection to Hastable.
>
><% con.ReleaseConnection(con) %>
>
>Could you please advice. I can write a Servlet too and load up the
>connections, but How do I get the connections by calling
>cpool.getConnection();
>
>If I make my bean Application Level,  Does this connections created only
>once and not loaded again again to Hastable. I have doubts about 
>Application
>
>scoping.
>
><jsp:useBean id="cpool" scope="application" class="ConnectionPool" />
>
>In case If you Application scoping,
>
>I still need to load the connections atleast once.
>does this work?
>< %cpool.createConnections(); %>
><% Connection c = cpool.getConnection()  %>
>
>Thanks  for your help in advance.
>
>--Anand

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.


Mime
View raw message