Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weblogic.db.jdbc
Class QueryDataSet

    java.lang.Object
      |
      +--weblogic.db.jdbc.DataSet
            |
            +--weblogic.db.jdbc.QueryDataSet

public final class QueryDataSet
extends DataSet

A QueryDataSet holds the results of an arbitrary SQL query. The results are available as a collection of Records accessible by an integer index. You can add new records and modify existing records of a QueryDataSet, but the additions and changes cannot be saved to the database. If you wish to save such changes, use a TableDataSet instead.

A QueryDataSet is constructed in the context of a Connection or a ResultSet.

The following example retrieves the query results into ds.

        QueryDataSet ds = new QueryDataSet(conn, "select * from tableA where f1 = 34");
        ds.fetchRecords();
        ds.close()  // This must be called

Pass an argument to fetchRecords() to set the size of the fetch. This example retrieves no more than the first 20 records of the query into ds and discards the remaining records by closing the DataSet.

        QueryDataSet ds = new QueryDataSet(conn, "select * from tableA where f1 = 34");
        ds.fetchRecords(20)
        ds.close()  // This must be called

The last example retrieves 100 records at a time into ds, does something, and then removes the records from the DataSet. This approach is useful for dealing with large query results.

        QueryDataSet ds = new QueryDataSet(conn, "select * from tableA, tableB where "
                                           + "tableA.f1 = tableB.f1");
        while (!ds.allRecordsRetrieved()) {
          ds.fetchRecords(100);
          // Do something with the 100 records...
          ds.clearRecords();
        }
        ds.close()  // This must be called

For more implementation and usage, see the Developers Guide.

Author:
  Copyright (c) 1995-1998 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1998-1999 by BEA Systems, Inc. All Rights Reserved.
See Also:
  `DataSet`, `SelectStmt`, `TableDataSet`, Serialized Form

Fields inherited from class weblogic.db.jdbc.DataSet
`cached, resetable, resultval, stmt`

Constructor Summary
`QueryDataSet()` Private - used for serialization
`QueryDataSet(java.sql.Connection conn, SelectStmt stmt)` QueryDataSet constructor.
`QueryDataSet(java.sql.Connection conn, java.lang.String sqlstr)` QueryDataSet constructor.
`QueryDataSet(java.sql.ResultSet results)` QueryDataSet constructor.

Method Summary
`java.lang.String` | `getSelectString()` Returns the SQL SELECT statement used to populate a QueryDataSet.
`java.sql.ResultSet` | `resultSet()` Returns the JDBC ResultSet associated with a QueryDataSet.

Methods inherited from class weblogic.db.jdbc.DataSet
`addRecord, allRecordsRetrieved, clearRecords, close, connection, containsRecord, destroy, fetchRecords, fetchRecords, fetchRecords, getRecord, getResultSet, initialize, lastFetchSize, maxColumnWidths, readExternal, releaseRecords, removeRecord, reset, schema, size, toString, writeExternal`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### QueryDataSet

    public QueryDataSet(java.sql.ResultSet results)
                 throws java.sql.SQLException,
                        DataSetException

  QueryDataSet constructor. The reset() method is unavailable on a QueryDataSet created with this constructor. Also, QueryDataSet.close() will not close the ResultSet argument of this constructor.

  Parameters:
    `results` - JDBC ResultSet
    `sqlstr` - SQL query string to specify data
  Throws:
    java.sql.SQLException - if there is a SQL error
    DataSetException - if there is an error creating the DataSet

### QueryDataSet

    public QueryDataSet(java.sql.Connection conn,
                        java.lang.String sqlstr)
                 throws java.sql.SQLException,
                        DataSetException

  QueryDataSet constructor. This constructor takes as an argument a string that is an arbitrary SQL statement.

  Parameters:
    `conn` - Connection object
    `sqlstr` - SQL query string to specify data
  Throws:
    java.sql.SQLException - if there is a SQL error
    DataSetException - if there is an error creating the DataSet

### QueryDataSet

    public QueryDataSet(java.sql.Connection conn,
                        SelectStmt stmt)
                 throws java.sql.SQLException,
                        DataSetException

  QueryDataSet constructor. Use a SelectStmt as an argument to set a SQL statement for this constructor. The SelectStmt class has methods for automatic SQL generation.

  Parameters:
    `db` - Connection object
    `stmt` - SelectStmt object to specify data
  Throws:
    java.sql.SQLException - if there is a SQL error
    DataSetException - if there is an error creating the DataSet

### QueryDataSet

    public QueryDataSet()

  Private - used for serialization

Method Detail

### getSelectString

    public java.lang.String getSelectString()

  Returns the SQL SELECT statement used to populate a QueryDataSet.

  Returns:
    SQL SELECT statement
  Overrides:
    getSelectString in class DataSet

### resultSet

    public java.sql.ResultSet resultSet()
                                 throws java.sql.SQLException,
                                        DataSetException

  Returns the JDBC ResultSet associated with a QueryDataSet.

  Returns:
    JDBC ResultSet
  Throws:
    java.sql.SQLException - if there is a SQL error
    DataSetException - if there is an error creating the DataSet
  Overrides:
    resultSet in class DataSet

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs70
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference