com.ibm.as400.util.servlet
Class SQLResultSetRowData

java.lang.Object
  extended by com.ibm.as400.util.servlet.RowData
      extended by com.ibm.as400.util.servlet.SQLResultSetRowData
All Implemented Interfaces:
Serializable

public class SQLResultSetRowData
extends RowData

The SQLResultSetRowData class represents an SQL ResultSet as a list of data. The ResultSet object is generated by an executed SQL statement.

An SQLResultSetRowData object maintains a position in the list that points to its current row of data. The initial position in the list is set before the first row. The next method moves to the next row in the list.

The getString method is used to retrieve the column value for the current row indexed by the column number. Columns are numbered starting from 0.

The number, types, and properties of the list's columns are provided by the SQLResultSetMetaData object returned by the getMetaData method.

The following example creates an SQLResultSetRowData object and initializes it to an SQL ResultSet.

  

// Register and get a connection to the database. DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver()); Connection connection = DriverManager.getConnection("jdbc:as400://mySystem");

// Execute an SQL statement and get the result set. Statement statement = connection.createStatement(); statement.execute("select * from qiws.qcustcdt"); ResultSet resultSet = statement.getResultSet();

// Create the SQLResultSetRowData object and initialize to the result set. SQLResultSetRowData rowData = new SQLResultSetRowData(resultSet);

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  ResultSet resultSet_
          The java.sql.ResultSet object associated with this RowData.
 
Fields inherited from class com.ibm.as400.util.servlet.RowData
rowProperties_, rows_
 
Constructor Summary
Constructor and Description
SQLResultSetRowData()
          Constructs a default SQLResultSetRowData object.
SQLResultSetRowData(ResultSet resultSet)
          Constructs a SQLResultSetRowData object with the specified resultSet.
 
Method Summary
Modifier and Type Method and Description
 void close()
          Closes the SQL result set.
 RowMetaData getMetaData()
          Returns the metadata.
 ResultSet getResultSet()
          Returns the SQL result set.
 void setResultSet(ResultSet resultSet)
          Sets the SQL result set.
 
Methods inherited from class com.ibm.as400.util.servlet.RowData
absolute, addPropertyChangeListener, addVetoableChangeListener, afterLast, beforeFirst, first, getCurrentPosition, getObject, getObjectProperties, getRowProperties, isAfterLast, isBeforeFirst, isFirst, isLast, last, length, next, previous, relative, removePropertyChangeListener, removeVetoableChangeListener, setObjectProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resultSet_

protected transient ResultSet resultSet_
The java.sql.ResultSet object associated with this RowData.

Constructor Detail

SQLResultSetRowData

public SQLResultSetRowData()
Constructs a default SQLResultSetRowData object.


SQLResultSetRowData

public SQLResultSetRowData(ResultSet resultSet)
                    throws RowDataException
Constructs a SQLResultSetRowData object with the specified resultSet. The remaining rows are read from the ResultSet starting at the current cursor position. The ResultSet is left in an open state with the cursor positioned after the last row. The ResultSet can be closed using the close method.

Parameters:
resultSet - The SQL result set. An empty result set is invalid.
Throws:
RowDataException - If the cursor state of the result set is invalid or a rowdata error occurs.
See Also:
close()
Method Detail

close

public void close()
           throws RowDataException
Closes the SQL result set.

Throws:
RowDataException - If a row data error occurs.

getMetaData

public RowMetaData getMetaData()
                        throws RowDataException
Returns the metadata.

Specified by:
getMetaData in class RowData
Returns:
The metadata.
Throws:
RowDataException - If a row data error occurs.

getResultSet

public ResultSet getResultSet()
Returns the SQL result set. Null is returned if the object was serialized. The result set data is cached during serialization.

Returns:
The SQL result set.

setResultSet

public void setResultSet(ResultSet resultSet)
                  throws RowDataException,
                         PropertyVetoException
Sets the SQL result set. The remaining rows are read from the ResultSet starting at the current cursor position. The ResultSet is left in an open state with the cursor positioned after the last row. The ResultSet can be closed using the close method. If a result set already exists, then setting the result set will remove all rows from the list before reading in the new data.

Parameters:
resultSet - The SQL result set. An empty result set is invalid.
Throws:
RowDataException - If the cursor state of the result set is invalid or a rowdata error occurs.
PropertyVetoException - If a change is vetoed.
See Also:
close()