On Sep 27, 6:29 pm, Arne VajhHj <a...@vajhoej.dk> wrote:
tes...@hotmail.com wrote:
Is it okay to create 3 different ResultSets with the same Statement
object? 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:
It is OK, but I think you should close the previous result set before
opening a new one.
You mean like this?
try {
results1 = statement.executeQuery("select name from
tableone");
if(results1.next())
{
int myvar = ....
}
....
finally {
//close results1 object only here
try {
results2 = statement.executeQuery("select name from
tableone");
if(results2.next())
{
int myvar = ....
}
....
finally {
//close results2 object only here
try {
results3 = statement.executeQuery("select name from
tableone");
if(results3.next())
{
int myvar = ....
}
....
finally {
//close results3 object only here
...
//Finally block here that closes results3,
statement and connection object references
That is one way.
finally if you do so in the third.