org.objectweb.cjdbc.controller.virtualdatabase
Class ControllerResultSet

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.virtualdatabase.ControllerResultSet
All Implemented Interfaces:
java.io.Serializable

public class ControllerResultSet
extends java.lang.Object
implements java.io.Serializable

A ControllerResultSet is a lightweight ResultSet for the controller side. It only contains row data and column metadata. The real ResultSet is constructed on by the driver on the client side from the ControllerResultSet information.

Version:
1.0
Author:
Emmanuel Cecchet
See Also:
DriverResultSet, Serialized Form

Field Summary
private  java.lang.String cursorName
          Cursor name for this ResultSet (not used yet)
private  java.util.ArrayList data
          The results
private  java.sql.ResultSet dbResultSet
          Backend ResultSet.
private  boolean dbResultSetClosed
          True if the underlying database ResultSet is closed
(package private)  DriverResultSet driverResultSet
          When streaming, hold a reference to the DriverResultSet we built so we don't have to re-compute everything.
private static java.util.ArrayList EMPTY_LIST
           
private  int fetchSize
          Fetch size if we need to fetch only a subset of the ResultSet
private  Field[] fields
          The fields
private  boolean hasMoreData
          True if there is still more data to fetch from dbResultSet
private  int maxRows
          Maximum number of rows remaining to fetch
private  java.sql.Statement owningStatement
          Optional statement dbResultSet is attached to if in streaming mode
 
Constructor Summary
ControllerResultSet(AbstractRequest request, java.sql.ResultSet rs, MetadataCache metadataCache, java.sql.Statement s)
          Build a C-JDBC ResultSet from a database specific ResultSet.
 
Method Summary
 void closeResultSet()
          Closes the database ResultSet to release the resource and garbage collect data.
 void fetchData()
          Fetch the next rows of data from dbResultSet according to fetchSize and maxRows parameters.
 void fetchData(int fetchSizeParam)
          Sets the fetch size and calls fetchData()
 java.lang.String getCursorName()
          Get the name of the SQL cursor used by this ResultSet
 java.util.ArrayList getData()
          Returns the data value.
 Field[] getFields()
          Returns the fields value.
 boolean hasMoreData()
          Returns the hasMoreData value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_LIST

private static final java.util.ArrayList EMPTY_LIST

data

private java.util.ArrayList data
The results


fields

private Field[] fields
The fields


cursorName

private java.lang.String cursorName
Cursor name for this ResultSet (not used yet)


fetchSize

private int fetchSize
Fetch size if we need to fetch only a subset of the ResultSet


dbResultSet

private transient java.sql.ResultSet dbResultSet
Backend ResultSet. We need to hold it when streaming.


owningStatement

private transient java.sql.Statement owningStatement
Optional statement dbResultSet is attached to if in streaming mode


dbResultSetClosed

private boolean dbResultSetClosed
True if the underlying database ResultSet is closed


hasMoreData

private boolean hasMoreData
True if there is still more data to fetch from dbResultSet


maxRows

private int maxRows
Maximum number of rows remaining to fetch


driverResultSet

DriverResultSet driverResultSet
When streaming, hold a reference to the DriverResultSet we built so we don't have to re-compute everything.

Constructor Detail

ControllerResultSet

public ControllerResultSet(AbstractRequest request,
                           java.sql.ResultSet rs,
                           MetadataCache metadataCache,
                           java.sql.Statement s)
                    throws java.sql.SQLException
Build a C-JDBC ResultSet from a database specific ResultSet. The metadata can be retrieved from the MetadataCache if provided. If a metadata cache is provided but the data is not in the cache, the MetadataCache is updated accordingly. The remaining code is a straightforward copy of both metadata and data.

The statement used to execute the query will be closed when the ResultSet has been completely copied or when the ResultSet is closed while in streaming mode.

Parameters:
request - Request to which this ResultSet belongs
rs - The database specific ResultSet
metadataCache - MetadataCache (null if none)
s - Statement used to get rs
Throws:
java.sql.SQLException - if an error occurs
Method Detail

fetchData

public void fetchData(int fetchSizeParam)
               throws java.sql.SQLException
Sets the fetch size and calls fetchData()

Parameters:
fetchSizeParam - the number of rows to fetch
Throws:
java.sql.SQLException - if an error occurs
See Also:
fetchData()

fetchData

public void fetchData()
               throws java.sql.SQLException
Fetch the next rows of data from dbResultSet according to fetchSize and maxRows parameters. This methods directly updates the data and hasMoreData fields returned by getData() and hadMoreData() accessors.

Throws:
java.sql.SQLException - from the backend or if dbResultSet is closed. Maybe we should use a different type internally.

getData

public java.util.ArrayList getData()
Returns the data value.

Returns:
Returns the data.

getFields

public Field[] getFields()
Returns the fields value.

Returns:
Returns the fields.

getCursorName

public java.lang.String getCursorName()
Get the name of the SQL cursor used by this ResultSet

Returns:
the ResultSet's SQL cursor name.

hasMoreData

public boolean hasMoreData()
Returns the hasMoreData value.

Returns:
Returns the hasMoreData.

closeResultSet

public void closeResultSet()
Closes the database ResultSet to release the resource and garbage collect data.



Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.