The init method is OK. One thing that most references suggest is to have the database connectivity
handled in a separate class that pools connections. I used a servlet class that was loaded with the Web server everytime and created the connections to the db. That way I just used the singleton instance of the
dbManager and it gives me a connection from the pool cache or if the pool is out create a new connection.
Of course, the decision on how and where your connectivity is required also depends on your application.



At 11:26 AM 05/22/2000 +0530, Vishal Salian wrote:
>Try giving the Class.forName() in the init method of the servlet .This will
>create only one instance.
>Regards,
>
>Vishal
>
>
>>From: Xu Jianwu <[EMAIL PROTECTED]>
>>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>>        Servlet API Technology." <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: Servlet with JDBC
>>Date: Mon, 22 May 2000 13:23:34 +0800
>>
>>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 Private, Free E-mail from MSN Hotmail at http://www.hotmail.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
>


Rajesh Nair
[EMAIL PROTECTED]
Ph: 913 599 7201

R&D
Informix Software

Reply via email to