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);
-
SQLResultSetRowData()
- Constructs a default SQLResultSetRowData object.
-
SQLResultSetRowData(ResultSet)
- Constructs a SQLResultSetRowData object with the specified resultSet.
-
absolute(int)
- Sets the position to the specified rowIndex.
-
afterLast()
- Sets the position after the last row in the list.
-
beforeFirst()
- Sets the position before the first row in the list.
-
close()
- Closes the SQL result set.
-
first()
- Sets the position to the first row in the list.
-
getCurrentPosition()
- Returns the current row position.
-
getMetaData()
- Returns the metadata.
-
getObject(int)
- Returns the current row's column data specified at columnIndex.
-
getObjectProperties(int)
- Returns the current row's property list for the specified columnIndex.
-
getResultSet()
- Returns the SQL result set.
-
getRowProperties()
- Returns the current row's property list.
-
isAfterLast()
- Indicates whether the current position is after the last row in the list.
-
isBeforeFirst()
- Indicates whether the current position is before the first row in the list.
-
isFirst()
- Indicates whether the current position is the first row in the list.
-
isLast()
- Indicates whether the current position is the last row in the list.
-
last()
- Sets the position to the last row in the list.
-
length()
- Returns the length of the result list.
-
next()
- Sets the position to the next row in the list.
-
previous()
- Sets the position to the previous row in the list.
-
relative(int)
- Sets the position a relative numberOfRows based on the current position.
-
setObjectProperties(Vector, int)
- Sets the column object's properties at the specified columnIndex.
-
setResultSet(ResultSet)
- Sets the SQL result set.
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
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
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
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
close
public void close() throws RowDataException
- Closes the SQL result set.
- Throws: RowDataException
- If a row data error occurs.
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
getCurrentPosition
public int getCurrentPosition()
- Returns the current row position.
- Returns:
- The row position (0-based).
- Overrides:
- getCurrentPosition in class RowData
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
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
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
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
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.
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
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
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
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
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
length
public int length()
- Returns the length of the result list.
- Returns:
- The length.
- Overrides:
- length in class RowData
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
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
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
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
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