Re: How to kill a connection
From: Herman Timmermans (timmermansdot.hermanat_at_skynet.be)
Date: 12/10/03
- Next message: Thomas Kellerer: "Re: Oracle Databases' list"
- Previous message: gnazio: "Re: How to kill a connection"
- In reply to: Bob Rivers: "How to kill a connection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Dec 2003 06:17:41 +0100
Bob Rivers wrote:
> Hi,
>
> I have a problem, and I don't know how to solve it.
>
> We have a web application (done in java/jsp, running under tomcat
> 4.1.29/j2sdk 1.4.2) that establishes a connection with postgres 7.3.2.
>
> We are using jdbc (7.3.1) to do it, but we are not using connection
> pool (my client security police determine that all connections to the
> database must be done per user basis).
>
> So, when the user do the login, we create a connection to this user.
> When the user closes the application, we close the connection. No
> problem, everything works well.
>
> But, if the user closes the window abnormally (for example, shutting
> down the browser window without clicking my application logoff button)
> the connection opened will be open forever.
>
> This connection will be killed only if I shutdown tomcat and/or
> postgres.
>
> My question is: How do I kill an idle connection?
>
> I don't want to do it manually. I was thinking about a thread that
> verifies the connection. If this connection is idle more that x
> minutes, I could kill it.
>
> Another way, is to setup a timeout for the connection. If it is idle
> for more that x minutes, postgres should kill it automatically.
>
> Is it possible? How do I do that?
>
> TIA,
>
> Bob
You should implement the HttpSessionListener interface. In case a session
is invalidated either by a pre-defined time-out or when the user closes his
browser, the sessionDestroyed method is called. Use this method to
clean-up whatever that needs to be done in your database when the user
forgets to do a proper logoff.
Brgds,
Herman
-- Suse Linux Professional 8.1 on Athlon 1.1 Ghz 512 Mb Anti Spam = remove the "dot" and the "at" Registered Linux User #264690
- Next message: Thomas Kellerer: "Re: Oracle Databases' list"
- Previous message: gnazio: "Re: How to kill a connection"
- In reply to: Bob Rivers: "How to kill a connection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]