IBM DB2 Manual page 56

Table of Contents

Advertisement

Table 7. ResultSet methods for positioning a scrollable cursor (continued)
Method
Notes:
1. This method does not apply to connections to IBM Informix Dynamic Server.
2. If the cursor is before the first row of the ResultSet, this method positions the cursor on
3. If the cursor is after the last row of the ResultSet, this method positions the cursor on
4. If the absolute value of n is greater than the number of rows in the result set, this
5. The cursor must be on a valid row of the ResultSet before you can use this method. If
6. Suppose that m is the number of rows in the ResultSet and x is the current row number
5. Invoke the close method to close the ResultSet object.
6. Invoke the close method to close the Statement or PreparedStatement object.
The following code demonstrates how to retrieve all rows from the employee table
in reverse order, and update the phone number for employee number "000010".
The numbers to the right of selected statements correspond to the
previously-described steps.
40
Application Programming Guide and Reference for Java
the first row.
the last row.
method positions the cursor after the last row if n is positive, or before the first row if n
is negative.
the cursor is before the first row or after the last row, the method throws an
SQLException.
in the ResultSet. If n>0 and x+n>m, the driver positions the cursor after the last row. If
n<0 and x+n<1, the driver positions the cursor before the first row.
b. If you need to know the current cursor position, use the getRow, isFirst,
isLast, isBeforeFirst, or isAfterLast method to obtain this information.
c. If you specified a resultSetType value of TYPE_SCROLL_SENSITIVE in step 1 on
page 38, and you need to see the latest values of the current row, invoke the
refreshRow method.
Recommendation: Because refreshing the rows of a ResultSet can have a
detrimental effect on the performance of your applications, you should
invoke refreshRow only when you need to see the latest data.
d. Perform one or more of the following operations:
v To retrieve data from each column of the current row of the ResultSet
object, use getXXX methods.
v To update the current row from the underlying table, use updateXXX
methods to assign column values to the current row of the ResultSet.
Then use updateRow to update the corresponding row of the underlying
table. If you decide that you do not want to update the underlying table,
invoke the cancelRowUpdates method instead of the updateRow method.
The resultSetConcurrency value for the ResultSet must be
CONCUR_UPDATABLE for you to use these methods.
v To delete the current row from the underlying table, use the deleteRow
method. Invoking deleteRow causes the driver to replace the current row
of the ResultSet with a hole.
The resultSetConcurrency value for the ResultSet must be
CONCUR_UPDATABLE for you to use this method.
Positions the cursor

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents