• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Statement and PreparedStatemnet---ORA-01000

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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().
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic