Hi:

Although it will save time during the servlet's request method is run and
will cut down on system resources (one connection for all requests).
Creating the connection in the init method is *not* always thread-safe.
Alot of JDBC implementations allow for multiple statements to be created
(sharing a connection over a thread) but not all do.  A safer approach would
be to create a pool of connections at start up and have each request access
a connection from the pool, possibly blocking if no connection is availible
or returning a page notifying the user that the system is busy and should
try again in a few minutes.

I know I have had problems in the past when I was using one connection
between multiple threads.

Chris Gow
[EMAIL PROTECTED]

> -----Original Message-----
> From: Cote, Stephane [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, August 04, 1999 7:26 PM
> To:   [EMAIL PROTECTED]
> Subject:      Thread safe JDBC connection
>
>
>
> Hi all.
>
>         Is loading a JDBC driver and making a connection in the servlets
> init() method a good practice from thread safety when concurrent instances
> of the servlet are created.
>
> Stef
>

___________________________________________________________________________
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