Discussion Locked

JDBC Connection becoming null

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm developing an application using Java servlets and JDBC. Right now I'm seeing a strange effect where at then end of the servlet process, I call the rollback method on the connection object, but it can't complete it because the Connection object has become null. The Connection object is stored as a private member variable of the UserStore class. It does have a method that sets it to null, but I have confirmed that it is not being called.

I'm also having a problem where the Connection object is open when it is obtained from the DriverManager, but becomes closed prior to its use in a query.

Can anyone shed any light on what might be causing these effects?

Thanks,

Steve Duran

4 replies

by emkay_mm

hi ,check your codes and see if
1.before calling the rollback you have mistakenly closed the connection object.
2.As far as second part is concerned it makes my belief stonger that the connection object is being unduly closed before the query. if nothing of this sort is found check to see if the class.forname,DriverManager, as well as the dsn name and its corresponding database are correctly linked.

by neo2032

I think we found out what was causing this problem. We have a "SmartServlet" that directs requests to the appropriate transaction classes. The system has to obtain a database connection that is customized for each user. We had this connection defined as a member variable of the SmartServlet. There's only one instance of this class, so apparently there's only one instance of the connection object, so when another user tries to perform a database operation, it grabs the connection and interferes with the earlier processes. We took the Connection object out of the SmartServlet, and the pesky problem has not showed it's face since.

This discussion is closed to new replies.