The answer is generally 'no'. Some JDBC driver implementations may support such a syntax, but it is far from standard. In the 'lucky' case that the first statement return 0 or 1 results (in which case it should be an 'if' statement not a 'while' loop), then it would not produce an error.
Where it is likely to produce an error is not on the second result set creation, but on the second call to rs.next().
"A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results."
Therefore when you call the second query on the original statement object, you force the first result set to be closed. Any future calls to the first result set, will produce an error. This does not mean you cannot use the same statement with multiple queries and result set, it just means you have to read the results in the order you execute them. Scattered results, such as those in nested events must be read using separate statements. [ February 01, 2006: Message edited by: Scott Selikoff ]
[ February 01, 2006: Message edited by: Vineela Devi ]
Not only is it not possible, it's probably not desireable. A good DBA who knows SQL well can probably write a JOIN query that will bring back all the data you need in one round trip with one Statement.
You're committing the "classic" sin of doing an (n+1) query. The query outside the loop returns n rows, and then you perform a network roundtrip evrey time you execute the loop. It'll perform like a pig if n is large, because network latency is the bottleneck.