wood burning stoves 2.0*
The moose likes JDBC and the fly likes Processing of Multiple Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Processing of Multiple Resultset" Watch "Processing of Multiple Resultset" New topic
Author

Processing of Multiple Resultset

Dibya G. Baruah
Greenhorn

Joined: Aug 08, 2002
Posts: 4
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.
Pat Wallwork
Ranch Hand

Joined: Sep 23, 2001
Posts: 72
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
 
wood burning stoves
 
subject: Processing of Multiple Resultset
 
Similar Threads
multiple processes... only want one
ResultSet Thru ResultSet
Retrive 4000 more records
How To Solve : java.sql.SQLException: Exhausted Resultset
stored procedures in a loop... what gives?