Your problem is that your session object (holding the connection) is not
being notified when the session is dropped. nb, when a user closes a browser
is not when the session will be dropped. You'll have to add i) a time out to
the session (say 10 minutes?) and ii) give the user a logout button so that
they can logout cleanly and promptly. See the Servlet specs for more
details.

An object in the session scope can request to be notified of when it is
removed from the session (usually because the session is being closed down).
Take a look at javax.servlet.http.HttpSessionBindingListener, it is an
interface with 2 methods on it. Just make your object implement this
interface and the bind/unbind method will be called when the object is added
to the session/removed from the session respectively. Using these
notifications your object will be able to open/close the database
connection.


Warning. If you're holding a connection open for such a long time, make sure
that you're not locking any tables in the database between user requests
otherwise the scaleable performance of the web site will drastically suffer.


- Chris

Brainbench MVP Java2.

> -----Original Message-----
> From: Raffaele Carlà [mailto:[EMAIL PROTECTED]]
> Sent: 16 March 2001 13:15
> To: [EMAIL PROTECTED]
> Subject: JDBC Connections
> 
> 
> Can anyone help me? I have:
> - SCO UnixWare 7.1.1
> - Informix Online 9.20 and JDBC 2.0
> - JDK 1.2.2
> - Tomcat 3.2.1
> When a make a JDBC connection to the DBMS with a JavaBean 
> (scope=session)
> and i close the browser, the connection remain up and it will 
> go down only
> after several hours.
> How can i do to set up a connection that dies when i close 
> the browser?
> Thank you.
> 
> 

Reply via email to