A better approach would be to use a connection pool that creates a number of
connections when your servlet starts up and for each request, you just get a
connection from the pool...that way you only have the overhead of creating
connections once. There are a number of ConnectionPool libraries availible
on the web just do a search. Or I think that JDBC 2.0 has some sort of
connectionPool class built in. If your JDBC driver supports 2.0 than you
may already have what you need.
Chris Gow
[EMAIL PROTECTED]
> -----Original Message-----
> From: Xizhen Wang [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, June 10, 1999 1:04 AM
> To: [EMAIL PROTECTED]
> Subject: Store DB connection in session in Servlet
>
> Hi!, All,
>
> I am writing a website with servlet that needs a lot of database work. I
> am wondering if it is a good idea that I retrieve a database connection
> when the user logins, then I put the connection in the session so that I
> can use it in subsequent servelts, and when the user logouts, I close
> the connection. In this way, I only need to build one connection at the
> beginning and operate the whole time with it. Maybe it is quicker than
> building connection everytime I need to access the database and closing
> after that. Can anyone give me some advice?
>
> 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
___________________________________________________________________________
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