Package quadbase.util

Interface IResultSet

All Superinterfaces:
IRow
All Known Implementing Classes:
DbData, DbData, 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.util.QueryResultSet implements the IResultSet interface over data from a JDBC data source.
  2. The class quadbase.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.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; iinvalid input: '<'=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; iinvalid input: '<'=nCol; i++) 
                        System.out.print("\t" + rs.getObject(i));
                System.out.println("");
        }
        rs.close();
   }
   ...
 

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the cursor
    Gets the meta data object
    boolean
    Advances cursor to next row

    Methods inherited from interface quadbase.util.IRow

    getObject