Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet usage

 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it okay to keep creating queries with the same ResultSet Object reference (results)? Here is what I am currently using in my Database statements with Oracle and everything works but was wondering if this is okay where I am using ResultSet results for 3 queries in my Tomcat container:

 
Paul Clapham
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. It's only a variable, so you can assign as many different objects as you like to it. It's the objects you have to worry about, not the variables. Which is why your code hinted at by "//close results..." is in the wrong place. When you finish using the first ResultSet object, you should close it before you lose the reference to it.
 
Dan Parsons
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I had to change it to where I create 3 different ResultSets with the same Statement object and closing the 3 different ResultSet objects in a finally block. Here is what I am currently using in my Database statements with Oracle and everything works great. But I am wondering if this will create Database resource leakages or other issues:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic