Given the code below:
//connection stuff
ResultSet rs = statement.executeQuery(query1);
statement.executeQuery(query2);
while(rs.next){
//code
}
Is the result set rs
still valid even though a second statement has been executed?
I know that when you close a statement the result set isn't valid any longer, but here the code is simply executing another query and not storing it in a result set.
Presuming
statement
is aStatement
, from the javadoc:The posted code is unsafe - the second call to
executeQuery
will return a newResultSet
, and given only one can be open at a timers
will not be valid.