tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arion" <ar...@talentinfo.com.hk>
Subject Re: JDBC and permanent connections
Date Fri, 19 May 2000 05:04:10 GMT
Hi!

Just initialize a servlet during server startup (in web.xml). Connect the
database and put the Connection object to ServletContext. Then all the other
servlet in the same context can reuse the connection object.

Arion

Michael Kostadinovich wrote:

> Hi!
>
> my question is not directly related to tomcat/jakarta, but I hope someone
> can still help me.
>
> I have to build a servlet which, among other things, connects to the
> database and executes some queries. In order to increase the performance, I
> want to connect to the database once (idealy in the init() method of the
> servlet) and then use this connection during the whole lifecycle of the
> servlet. Because of the expection the driverManager's getConnection() throws
> I cannot use a connection build in one method's try{..} block in another
> method. Is there any technique to build the connection once (idealy in the
> init() method) and use this connection in the whole scope of a servlet (in
> doGet(), doPost() and service())?
>
> Thanks
>
> Michael Kostadinovich
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message