| Author |
ResultSet usage
|
Dan Parsons
Ranch Hand
Joined: May 30, 2007
Posts: 70
|
|
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
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
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
Joined: May 30, 2007
Posts: 70
|
|
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:
|
 |
 |
|
|
subject: ResultSet usage
|
|
|