Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet question

 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey folks,
the code:
-----------
ResultSet r1=statement.executeQuery(select * a);
ResultSet r2=statement.executeQuery(select * b);
-----------
for some reason r1 is ok, but r2 is empty.
if i make a totally new statement for the second ResultSet, like this:
-----------
ResultSet r1=statement1.executeQuery(select * a);
ResultSet r2=statement2.executeQuery(select * b);
-----------
everything works fine.
i just don't want to open another connection to make a second statement, and i have examples where the first solution works fine. any ideas what is the problem?
thnx
 
Pat Wallwork
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the api:
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.

So in your case you should have 2 separate statement objects.
-Pat
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create two statement objects from the same connection object, so you don't necessarily have more connections.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic