• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc database connection (not being closed)

 
Ravi Danum
Ranch Hand
Posts: 148
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am working on a legacy web application that issues jdbc commands from jsps. The jdbc database connection is issued once in the beginning from some java initialization code.

After awhile, the database access gets very slow. I fear that the connection is never closed when the user logs out or an exception is thrown. Where should I close the database connection without using connection pooling?

If I have to use connection pooling, what product would you recommend?

Thanks for your help and time.

-ravi

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so let me check what you are saying.
The database connection is opened when the webapp is started and the same connection is used all the time until the webapp is shut down?
Or is it just once per session?

so i bet whoever designed this didn't think to close any statement or result sets.

Finding and closing every statement, prepared statement and result set in a finally block, would be the very first thing to do.

and close the connection whenever it is finished with would be the second job.
 
Ravi Danum
Ranch Hand
Posts: 148
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy,

The connection is obtained when the webapp comes up and stored in the servletContext.

Most of the statements have been closed (I closed the the ones that weren't)...none of the resultsets have been closed. The same ResultSet object is used for a given jsp.

Since the same connection is used for all clients, would you recommend using a connection pool?

Thanks.

Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic