Class CachedResultSet

java.lang.Object
net.sourceforge.jtds.jdbc.JtdsResultSet
net.sourceforge.jtds.jdbc.CachedResultSet
All Implemented Interfaces:
AutoCloseable, ResultSet, Wrapper

public class CachedResultSet extends JtdsResultSet
A memory cached scrollable/updateable result set.

Notes:

  1. For maximum performance use the scroll insensitive result set type.
  2. As the result set is cached in memory this implementation is limited to small result sets.
  3. Updateable or scroll sensitive result sets are limited to selects which reference one table only.
  4. Scroll sensitive result sets must have primary keys.
  5. Updates are optimistic. To guard against lost updates it is recommended that the table includes a timestamp column.
  6. This class is a plug-in replacement for the MSCursorResultSet class which may be advantageous in certain applications as the scroll insensitive result set implemented here is much faster than the server side cursor.
  7. Updateable result sets cannot be built from the output of stored procedures.
  8. This implementation uses 'select ... for browse' to obtain the column meta data needed to generate update statements etc.
  9. Named forward updateable cursors are also supported in which case positioned updates and deletes are used referencing a server side declared cursor.
  10. Named forward read only declared cursors can have a larger fetch size specified allowing a cursor alternative to the default direct select method.
Version:
$Id: CachedResultSet.java,v 1.26 2007-07-08 17:28:23 bheineman Exp $
Author:
Mike Hutchinson
To do:
Should add a "close statement" flag to the constructors
  • Field Details

    • onInsertRow

      protected boolean onInsertRow
      Indicates currently inserting.
    • insertRow

      protected ParamInfo[] insertRow
      Buffer row used for inserts.
    • updateRow

      protected ParamInfo[] updateRow
      The "update" row.
    • rowUpdated

      protected boolean rowUpdated
      Indicates that row has been updated.
    • rowDeleted

      protected boolean rowDeleted
      Indicates that row has been deleted.
    • tempResultSet

      protected final boolean tempResultSet
      True if this is a local temporary result set.
    • cursorTds

      protected final TdsCore cursorTds
      Cursor TdsCore object.
    • updateTds

      protected final TdsCore updateTds
      Updates TdsCore object used for positioned updates.
    • isSybase

      protected boolean isSybase
      Flag to indicate Sybase.
    • sizeChanged

      protected boolean sizeChanged
      Fetch size has been changed.
    • sql

      protected String sql
      Original SQL statement.
    • procName

      protected final String procName
      Original procedure name.
    • procedureParams

      protected final ParamInfo[] procedureParams
      Original parameters.
    • isKeyed

      protected boolean isKeyed
      Table is keyed.
    • tableName

      protected String tableName
      First table name in select.
    • connection

      protected JtdsConnection connection
      The parent connection object
  • Constructor Details

    • CachedResultSet

      CachedResultSet(JtdsStatement statement, String sql, String procName, ParamInfo[] procedureParams, int resultSetType, int concurrency) throws SQLException
      Constructs a new cached result set.

      This result set will either be cached in memory or, if the cursor name is set, can be a forward only server side cursor. This latter form of cursor can also support positioned updates.

      Parameters:
      statement - the parent statement object
      sql - the SQL statement used to build the result set
      procName - an optional stored procedure name
      procedureParams - parameters for prepared statements
      resultSetType - the result set type eg scrollable
      concurrency - the result set concurrency eg updateable
      Throws:
      SQLException - if an error occurs
    • CachedResultSet

      CachedResultSet(JtdsStatement statement, String[] colName, int[] colType) throws SQLException
      Constructs a cached result set based on locally generated data.
      Parameters:
      statement - the parent statement object
      colName - array of column names
      colType - array of corresponding data types
      Throws:
      SQLException - if an error occurs
    • CachedResultSet

      CachedResultSet(JtdsResultSet rs, boolean load) throws SQLException
      Creates a cached result set with the same columns (and optionally data) as an existing result set.
      Parameters:
      rs - the result set to copy
      load - load data from the supplied result set
      Throws:
      SQLException - if an error occurs
    • CachedResultSet

      CachedResultSet(JtdsStatement statement, ColInfo[] columns, Object[] data) throws SQLException
      Creates a cached result set containing one row.
      Parameters:
      statement - the parent statement object
      columns - the column descriptor array
      data - the row data
      Throws:
      SQLException - if an error occurs
  • Method Details