You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by muralipn <mu...@accord-soft.com> on 2002/09/06 09:29:52 UTC
Problem related to closing Database connection
Hello
I have opened a database connection and how to do I close this
connection
a. when the server is closed normal through proper shutdown process
like
in Tomcat 4.0 , shutdown.bat
b. when the server is closed abnormally say crashed because of some
action
In the above stated conditions , how do I close the database
connection
so that I can be sure that database connection is closed and when
the
server is started again a fresh new database connection is created
ThanX in advance
Murali
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem related to closing Database connection
Posted by Benny Lootens <be...@verzekeringen.be>.
Hi Murali,
The only proper way to this, is to add a shutdownhook. This is an
ordinary thread-class (a class that implements Runnable), that will
automatically be executed at the end of the current jvm, even when it's
crashed. You can in the thread-class close your database connections.
When you created your threadclass, you can add it at the start of your
application somewhere in de code via:
// adding shutdown hook somewhere in your code
Runtime.getRuntime().addShutdownHook(new MyShutdownHookClass());
regards,
benny lootens
On Fri, 2002-09-06 at 09:29, muralipn wrote:
> Hello
>
> I have opened a database connection and how to do I close this
> connection
>
> a. when the server is closed normal through proper shutdown process
> like
> in Tomcat 4.0 , shutdown.bat
>
> b. when the server is closed abnormally say crashed because of some
> action
>
> In the above stated conditions , how do I close the database
> connection
> so that I can be sure that database connection is closed and when
> the
> server is started again a fresh new database connection is created
>
>
> ThanX in advance
> Murali
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>