This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Processing of Multiple Resultset  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three resultsets which needs to be processed in while loop. The code is like this:
//Statement stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt1.executeQuery(reportQuery1);
ResultSet rs2 = stmt1.executeQuery(reportQuery2);
ResultSet rs3 = stmt1.executeQuery(reportQuery3);
while (rs.next()){
rs2.first();
while (rs2.next(){
/// Pocessing
}
}
if the 'rs' is empty then it is giving me null pointer exception in the first while loop.My understanding is that even if the resultset(rs) is empty it should not give me null pointer exception. Please advice.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For each ResultSet you need to specify a separate Statement. This is right in the API...


By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.


hth,
-Pat
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!