File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Processing of Multiple Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Processing of Multiple Resultset" Watch "Processing of Multiple Resultset" New topic

Processing of Multiple Resultset

Dibya G. Baruah

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 ({
while ({
/// 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.

I agree. Here's the link:
subject: Processing of Multiple Resultset
It's not a secret anymore!