The issue is with the scheme you retrieve data in
getStuff(). Every time you visit
getStuff() you gain a fresh
ResultSet however you don't close it.
By default, just one ResultSet object per Statement object can be open at the same time. Hence, in case the reading of one ResultSet object is interleaved with the reading of another, each should have been originated by diverse Statement objects. All execution systems in the Statement interface implicitly close a statment's recent ResultSet object in case an open one subsists.
What creates things even worse is the
rs from the calling code. It is further executed off-of the
statement field however it is not closed.
Bottom line: you have various
ResultSet concerning to the same
Statement object concurrently unveiled.
A ResultSet object is automatically closed at the time the Statement object that originated it is closed, re-executed, or exercised to fetch the next result from a sequence of multiple results.
I guess after
while(rs2.next()) you are attempting to access something from rs1. However, it's meanwhile closed because you reexecuted statement to get rs2 from it. Because you didn't close it, I beleive it's exercised again below.