All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.util.servlet.SQLResultSetRowData

java.lang.Object
   |
   +----com.ibm.as400.util.servlet.RowData
           |
           +----com.ibm.as400.util.servlet.SQLResultSetRowData

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 getObject 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);


Constructor Index

 o SQLResultSetRowData()
Constructs a default SQLResultSetRowData object.
 o SQLResultSetRowData(ResultSet)
Constructs a SQLResultSetRowData object with the specified resultSet.

Method Index

 o absolute(int)
Sets the position to the specified rowIndex.
 o afterLast()
Sets the position after the last row in the list.
 o beforeFirst()
Sets the position before the first row in the list.
 o close()
Closes the SQL result set.
 o first()
Sets the position to the first row in the list.
 o getCurrentPosition()
Returns the current row position.
 o getMetaData()
Returns the metadata.
 o getObject(int)
Returns the current row's column data specified at columnIndex.
 o getObjectProperties(int)
Returns the current row's property list for the specified columnIndex.
 o getResultSet()
Returns the SQL result set.
 o getRowProperties()
Returns the current row's property list.
 o isAfterLast()
Indicates whether the current position is after the last row in the list.
 o isBeforeFirst()
Indicates whether the current position is before the first row in the list.
 o isFirst()
Indicates whether the current position is the first row in the list.
 o isLast()
Indicates whether the current position is the last row in the list.
 o last()
Sets the position to the last row in the list.
 o length()
Returns the length of the result list.
 o next()
Sets the position to the next row in the list.
 o previous()
Sets the position to the previous row in the list.
 o relative(int)
Sets the position a relative numberOfRows based on the current position.
 o setObjectProperties(Vector, int)
Sets the column object's properties at the specified columnIndex.
 o setResultSet(ResultSet)
Sets the SQL result set.

Constructors

 o SQLResultSetRowData
 public SQLResultSetRowData()
Constructs a default SQLResultSetRowData object.

 o 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

Methods

 o absolute
 public boolean absolute(int rowIndex)
Sets the position to the specified rowIndex. Attempting to move beyond the first row will move to the position before the first row. Attempting to move beyond the last row will move to the position after the last row.

Parameters:
rowIndex - The row index (0-based). The rowIndex must be zero or a positive integer which is less than the number of rows.
Returns:
true if the requested position exists; false otherwise.
Overrides:
absolute in class RowData
 o afterLast
 public void afterLast()
Sets the position after the last row in the list. This is a valid position after the end of the list.

Overrides:
afterLast in class RowData
 o beforeFirst
 public void beforeFirst()
Sets the position before the first row in the list. This is a valid position before the beginning of the list.

Overrides:
beforeFirst in class RowData
 o close
 public void close() throws RowDataException
Closes the SQL result set.

Throws: RowDataException
If a row data error occurs.
 o first
 public boolean first()
Sets the position to the first row in the list.

Returns:
true if the requested position exists; false otherwise.
Overrides:
first in class RowData
 o getCurrentPosition
 public int getCurrentPosition()
Returns the current row position.

Returns:
The row position (0-based).
Overrides:
getCurrentPosition in class RowData
 o getMetaData
 public RowMetaData getMetaData() throws RowDataException
Returns the metadata.

Returns:
The metadata.
Throws: RowDataException
If a row data error occurs.
Overrides:
getMetaData in class RowData
 o getObject
 public Object getObject(int columnIndex) throws RowDataException
Returns the current row's column data specified at columnIndex.

Parameters:
columnIndex - The column index (0-based).
Returns:
The column object.
Throws: RowDataException
If a row data error occurs.
Overrides:
getObject in class RowData
 o getObjectProperties
 public Vector getObjectProperties(int columnIndex)
Returns the current row's property list for the specified columnIndex.

Parameters:
columnIndex - The column index (0-based).
Returns:
The property list for the column data object.
Overrides:
getObjectProperties in class RowData
 o getRowProperties
 public Vector[] getRowProperties()
Returns the current row's property list.

Returns:
The property lists for each data object in the row.
Overrides:
getRowProperties in class RowData
 o 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.
 o isAfterLast
 public boolean isAfterLast()
Indicates whether the current position is after the last row in the list. This is a valid position after the end of the list.

Returns:
true if the position is after the last row; false otherwise.
Overrides:
isAfterLast in class RowData
 o isBeforeFirst
 public boolean isBeforeFirst()
Indicates whether the current position is before the first row in the list. This is a valid position before the beginning of the list.

Returns:
true if the position is before the first row; false otherwise.
Overrides:
isBeforeFirst in class RowData
 o isFirst
 public boolean isFirst()
Indicates whether the current position is the first row in the list.

Returns:
true if the position is the first row; false otherwise.
Overrides:
isFirst in class RowData
 o isLast
 public boolean isLast()
Indicates whether the current position is the last row in the list.

Returns:
true if the position is the last row; false otherwise.
Overrides:
isLast in class RowData
 o last
 public boolean last()
Sets the position to the last row in the list.

Returns:
true if the requested position exists; false otherwise.
Overrides:
last in class RowData
 o length
 public int length()
Returns the length of the result list.

Returns:
The length.
Overrides:
length in class RowData
 o next
 public boolean next()
Sets the position to the next row in the list. The list is initially positioned before its first row. The first call to next makes the first row the current row, the second call makes the second row the current row, etc. Moving beyond last row in the list will result in a position after the last row.

Returns:
true if the requested position exists in the list; false if there are no more rows.
Overrides:
next in class RowData
 o previous
 public boolean previous()
Sets the position to the previous row in the list. Moving beyond the first row in the list will result in a position before the first row.

Returns:
true if the requested position exists in the list; false otherwise.
Overrides:
previous in class RowData
 o relative
 public boolean relative(int numberOfRows)
Sets the position a relative numberOfRows based on the current position. Moving beyond the first/last row in the list will result in a position before/after the first/last row.

Parameters:
numberOfRows - The number of rows to move, either positive or negative.
Returns:
true if the requested position exists; false otherwise.
Overrides:
relative in class RowData
 o setObjectProperties
 public void setObjectProperties(Vector properties,
                                 int columnIndex)
Sets the column object's properties at the specified columnIndex.

Parameters:
properties - The properties.
columnIndex - The column index (0-based).
Overrides:
setObjectProperties in class RowData
 o 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.
Throws: PropertyVetoException
If a change is vetoed.
See Also:
close

All Packages  Class Hierarchy  This Package  Previous  Next  Index