As I already answered the first question, here is the second.
Store the reference to the pool as a session object using lazy instantiation.
(http://www.javaworld.com/javaworld/javatips/jw-javatip67.html) :

ConnectionPool connpool = (ConnectionPool) session.getAttribute("theConnectionPool");
if (connpool == null){
conPool = utilityMethodReturningAConnectionpool());
 session.setAttribute(

--- Anoop Kumar V <[EMAIL PROTECTED]> wrote:
> We have a system consisting of a group of jsps - which have links to one
> another. There is no controller servlet as it is a simple system. What i
> want is to access the database from the jsps. The problem is that I do not
> want a new connection to be established everytime a request is made. What is
> the solution for this?
> I had initially thought of having a utility class and in that I can have a
> getConnection method which returns the connection to a static connection
> reference in the same utility class. This can then be assigned to the jsps
> (by making a call from the jsps to some method - returnConn, in the utilily
> class). Is it true that a new connection will be established everytime. This
> has confused me a bit.
> I am infact confused now about the very concept of static references. How do
> you think this problem can be solved? Will a servlet be of any use? Actually
> in a servlet, if we have a static connection reference as a class variable,
> and the initialization is done ( acquiring a connection) in the init method
> ( as init is executed only once in the lifetime of a servlet), the problem
> may be solved. In a servlet, the init method is executed only once and the
> servlet does not go out of memory till the server comes down. So I presume
> the connection will also be the same. Is this correct? Even if it is, I want
> to avoid the servlet, as it will be a lot of rework if the servlet has to be
> fit in. The application would have to be changed. Suggestions invited.
>
>
> Anoop Kumar V.
>
>
>


=====

Mark Zawadzki Performance Engineer/DBA/Programmer extraordinaire’ [EMAIL PROTECTED] 
[EMAIL PROTECTED]

 "Democracies die behind closed doors," - Judge Damon Keith


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to