>In testing I have noticed that if a user runs a servlet that does some
>database access and hits "stop" (the X in IE for example) while the
>database connection is still open, then the database connection remains
>open. This will eventually cause problems if we have 100+ users and say
>25% of them do this often.
Yes, I have dealt with this problem before, you need to make sure that you
close or return them to a pool every time you take them out.
Here's one suggestion that might help.
Once your servlet starts running, it won't just quit arbitrarily because
the client pressed stop, because pressing stop doesn't actually communicate
with the server. Usually what happens is that your code keeps running and
dies whenever it starts writing to the response output stream. (This
usually shows up for me as a broken pipe exception, but different servers
may respond differently.
However, you can catch this Exception and close the connection there too,
making sure it is always closed. Try something like this
Connection conn = null;
try
{
conn = getConnection();
/** processing **/
/** begin outputting **/
}
catch (Exception e)
{
/** do something depending on the type of exception **/
}
finally
{
cleanUpConnection(conn);
}
___________________________________________________________________________
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