EspressReport 6.6

quadbase.reportdesigner.util
Interface IResultSet

All Superinterfaces:
IRow
All Known Implementing Classes:
DbData, DbDataCollection, QueryResultSet, StreamResultSet, XMLQueryResultSet, XMLResultSet

public interface IResultSet
extends IRow

This interface is used to read data in a tabular form. This is similar to the java.sql.ResultSet interface used to read from a JDBC data source. (However, it is much simpler). The interface can be implemented over data from any data source such as a database, a data file, or data in memory. The following are some sample implementations :

  1. The class quadbase.reportdesigner.util.QueryResultSet implements the IResultSet interface over data from a JDBC data source.
  2. The class quadbase.reportdesigner.util.StreamResultSet implements the IResultSet interface over data from an input stream such as a data file in the *.dat format supported by the chart.
  3. The class quadbase.ChartAPI.DbData implements the IResultSet interface over data from arrays.
The model for the interface is a result set with a forward-only cursor. The cursor is initially positioned before the first row. Each call of the next() method causes the cursor to advance by one row. The getObject(int) method (in the parent IRow interface) may then be used to read the contents of each row, namely the values for each column. Note that the column indexes begin at 1 (and not 0). The close method closes the cursor. Once a cursor has been closed, data is no longer available.

The information about the table structure, such as the number, names, and data types of the columns are provided by the IRSMetaData interface.


 
 import quadbase.reportdesigner.util.*;
 
   ...// other code
 
   ////// Print the given result set ///////
   public void printResultSet(IResultSet rs) throws Exception {
        IRSMetaData md = rs.getMetaData();
        int nCol = md.getColumnCount();
        int nRow = 0;
 
        // Print the column names and data type constants :
        for(int i=1; i<=nCol; i++) {
                System.out.print("\t" 
                        + md.getColumnName(i) +"["+ md.getColumnType(i) +"]");
        }
 
        // Get records :
        while(rs.next()) {
                System.out.println(++nRow);
                for(int i=1; i<=nCol; i++) 
                        System.out.print("\t" + rs.getObject(i));
                System.out.println("");
        }
        rs.close();
   }
   ...
 

See Also:
IRSMetaData, StreamResultSet, QueryResultSet, DbData

Method Summary
 void close()
          Closes the cursor
 IRSMetaData getMetaData()
          Gets the meta data object
 boolean next()
          Advances cursor to next row
 
Methods inherited from interface quadbase.reportdesigner.util.IRow
getObject
 

Method Detail

next

boolean next()
             throws java.lang.Exception
Advances cursor to next row

Throws:
java.lang.Exception

close

void close()
           throws java.lang.Exception
Closes the cursor

Throws:
java.lang.Exception

getMetaData

IRSMetaData getMetaData()
                        throws java.lang.Exception
Gets the meta data object

Throws:
java.lang.Exception

EspressReport 6.6