Hello,
I think your aim is to connect to database only once for an instance of the
servlet;for all the threads. Right?
So do so, you must create the database connection only inside the init() method of
your servlet. This is because the init method is executed only once in the life time
of the servlet , invoked by the server.
To be more, precise you can disconnect from the database when the servlet is to be
destroyed; in the destroy() method.
Bye,
veena.
---
Assistant Profesor,
Manipal Center for Information Science,
Manipal.
576 119
Email: [EMAIL PROTECTED]
Telephone: 91+08252-71915/71914
On Mon, 22 May 2000 13:23:34 Xu Jianwu wrote:
>I am developing servlets with JDBC API to access my database. In order to ensure that
>the database connection is created only once for the threads of a servlet, where or
>when should I Class.forName() and DriveManager.getConnection()? Should I override the
>construction method of (e.g.) HttpServlet and do them there?
>
Get your FREE Email at http://mailcity.lycos.com
Get your PERSONALIZED START PAGE at http://my.lycos.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