It's not strictly 'passing ' a connection , but I use a connection pool class
to avoid keeping on opening and closing db connections . Here's how
Most servlet engines should allow you to specify a class or classes to run on
server start. I run a DBInit class which creates a db connections until it
reaches some limit (I specify ten for a medium sized intranet site, but they
never block). Then whenever I need a connection I call a factory method on my
DBInit class. This method checks whether any DB connections are available and
returns one or waits if all are in use until one is free.
There are many such database pool classes available , maybe one even ships with
your servlet engine.
Hope this helps
Baris EFE wrote:
> Hi,
> I have a servlet with html output some of them have link to another
> servlet.
> I want to use connection object from other servlet not to open another
> connection to DB. What is(or are) the way of doing it?
> Thanks!!
>
> ___________________________________________________________________________
> 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
--
Tim Stephenson
-----------------------------------------------------------
e: [EMAIL PROTECTED] or [EMAIL PROTECTED]
m: +44 7775 66 00 58
h: +44 207 254 5196
v: +44 1628 597279
a: Flat 5, 90 Southgate Road, London. UK. N1 3JD
-----------------------------------------------------------
___________________________________________________________________________
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