Inactive Oracle Sessions due to JSP

F

Fahd Shariff

I have a web application made up of JSPs and Servlets. The JSPs connect
to a database via JDBC connections in order to execute queries and
return results. I have noticed that there are a number of "inactive
sessions" appearing in the Oracle database which have been created by
these JSPs connecting to the database. These sessions, when in large
numbers, affect database performance and I have to go into the database
and kill them off manually.

I have double checked and am positive that all connections and
statements are being closed within my JSPs and have no idea why these
inactive sessions are still appearing. Has anyone faced similar
problems?

Could this be because some users might be closing down their browsers
while the page is still loading? Or clicking on a link twice in
succession?
 
E

enrique

Hard to say for sure without being intimate with your particular
application(s). However, terminating the http session before the
database transation seems like a reasonable explanation. Maybe one way
these can be addressed is by catching exceptions in the Java code
whenever "no one is home" when the results are returned to the browser.
If you can detect when the session is ended before the database
transation completes, you can programmtically close the connection.

epp
 
F

Fahd Shariff

After lots of fiddling around here is how I resolved the problem:

Instead of simply calling close() methods I set them to null as well:

if (statement != null) {
statement.close();
statement = null;
}
if (connection != null) {
connection.close();
connection = null;
}

Apparently what this does is it allows the garbage collector to do its
thing on these objects.

I also made sure I closed all my resultSets in a similar way.

As a result I now have ZERO inactive sessions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top