At 07:04 рм 6/9/2000 -0600, you wrote:
>Chin Cedric Sung Kit wrote:
> >
> > i initialize my oracle-jdbc
> > database connection in my LoginServlet.  how do i re-use this connection
> > in my other jsp pages, so that i will not have to open so many
> > connections?
>
>You don't re-use your connection. At a minimum, you should use a new
>connection for every session. If you try to use the same connection for
>every request, you will have concurrency problems.

This is completely wrong. You can share a single java.sql.Connection
instance among many threads. Synchronization issues appear in the context
of java.sql.Statement instances, which again can be shared among many
threads but with care.

I have personally build a db engine implemented as singleton to be used and
shared among many servlets running under the same JVM process. The db
engine opens a certain amount of connection to the database subsystem (2-3
are just enough) and share them to all running threads, which in the case
of servlets may be quite a lot!

Cheers
Filippos Slavik



################################################################
Filippos Slavik
Forthnet R&D, Hrakleio, Greece
e-mail : [EMAIL PROTECTED]
phone : (+3) 081 391230
################################################################

"The software said 'runs on Win95 or better,' so I installed it
on Linux..."

___________________________________________________________________________
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