This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Statement and PreparedStatemnet---ORA-01000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Statement and PreparedStatemnet---ORA-01000 " Watch "Statement and PreparedStatemnet---ORA-01000 " New topic
Author

Statement and PreparedStatemnet---ORA-01000

sreedhar lak
Ranch Hand

Joined: Feb 26, 2006
Posts: 42
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
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
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...


PreparedStatement is a sub-class of Statement, so you can correctly use a PreparedStatement object (or a CallableStatement object) when you call closeDBStuff().
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statement and PreparedStatemnet---ORA-01000
 
Similar Threads
ORA-01000 error using WEBLOGIC server
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
ORA-01000 maximum open cursors exceeded