aspose file tools*
The moose likes JDBC and the fly likes JDBC connection closing problem in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC connection closing problem in Servlets" Watch "JDBC connection closing problem in Servlets" New topic
Author

JDBC connection closing problem in Servlets

Vikram Anand
Greenhorn

Joined: May 17, 2002
Posts: 10
In my code I open the connection in the init() method of the servlet and close it in the destroy method.
after some inputs to the database the database returns a error telling the connection is already in use with stmt already in use.
i am using sql server with jdbc-odbc.
plz help
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Probably need to see your Servlet Code before anyone can help you.


GenRocket - A Test Data Generation Platform
Narendra Kamaraju
Greenhorn

Joined: Jul 18, 2001
Posts: 16
narendra.kamaraju@oracle.com

Hi Vikarm,
After creating the conneciton in the init() method,if you start invoking the servlet repeatedly over a period of time,it is going to open a cursor for each statement that you execute.Any database connection will have ceiling on maximum number of open cursors that it maintain for a single connection.Make sure that you close the statement and resultset once you are done with your work.
If you post your code here,I can tell you what exactly needs to be done.

Best of luck,
Cheers,
Narendra.
[ July 11, 2002: Message edited by: Narendra Kamaraju ]

Narendra Kamaraju
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by Narendra Kamaraju:
narendra.kamaraju@oracle.com

Um, yeah. 'cos that helps
Generally we try to encourage people to discuss solutions on the boards so that others can benefit from the solutions too. If you find it's something that you want to work over privately, that's fine, but it ends up helping one person rather than, um, lots.
Narendra Kamaraju
Greenhorn

Joined: Jul 18, 2001
Posts: 16
Originally posted by David O'Meara:

Um, yeah. 'cos that helps
Generally we try to encourage people to discuss solutions on the boards so that others can benefit from the solutions too. If you find it's something that you want to work over privately, that's fine, but it ends up helping one person rather than, um, lots.


Hi David,
It was not intentional to post the query without any content.I have edited my post immediately to correct my mistake.
Sorry once again.
Regards,
Narendra
 
 
subject: JDBC connection closing problem in Servlets
 
Similar Threads
Queries regarding PreparedStatement
id of the new field in my table
DB2 JDBC connection
Problem
Calling java code in an Oracle DB using RMI ?