Hi All, I am facing one problem in my application only some times. The problem description shows it is regarding cursors opened (ORA-01000). Please see the code below... closeDBStuff(Connection con, Statement pStmt, ResultSet rs){
if (rs != null) rs.close(); if (pStmt != null) pStmt.close(); if (con != null) con.close(); con=null; rs=null; pStmt=null; } I am calling this method from all my methods from a finally{} only. My doubt is: Suppose if i created an object/ref to PreparedStatement in one method and in that finally i am calling closeDBStuff() method by passing this PS ,it is not giving any error even this closeDBStuff() is expecting Statement obj.but my doubt is whether it is really closing that obj. Please help me in this regard...
Thanks a lot<br />Learn from yesterday, live for today, hope for tomorrow. The important thing is to not stop questioning
Martin Simons
Ranch Hand
Joined: Mar 02, 2006
Posts: 196
posted
0
it is closing it, but it is not "dereferencing" the original variable that was passed in using the "= null" statements at the end of the method. The original variables will still reference the objects they referenced before the method call, because Java passes all parameters by value, it is just that the passed value of a reference will still refer to the same object, but is still only a copy of the original reference, so, reassigning this reference variable to null in the method will still leave the original reference untouched.
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
Originally posted by sreedhar lak:
My doubt is: Suppose if i created an object/ref to PreparedStatement in one method and in that finally i am calling closeDBStuff() method by passing this PS ,it is not giving any error even this closeDBStuff() is expecting Statement obj.but my doubt is whether it is really closing that obj. Please help me in this regard...