Java Reference
In-Depth Information
Fig. 7.5 Output from program JDBCScrollableSelect
In this example, we had no need to move explicitly past the end of the data rows
before we started traversing the rows in reverse order, since the cursor was conve-
niently positioned beyond the last row at the end of the forward traversal. If this had
not been the case, however, we could easily have positioned the cursor beyond the
last row by invoking method afterLast . For example:
results.afterLast();
Analogous to this method, there is a method called beforeFirst that will position
the cursor before the fi rst row of the ResultSet . Another method that is occasionally
useful is getRow , which returns the number of the current row.
7.11
Modifying Databases via Java Methods
Another very useful feature of the JDBC API is the ability to modify ResultSet rows
directly via Java methods (rather than having to send SQL statements), and to have
those changes refl ected in the database itself ! In order to do this, it is necessary
to use the second version of createStatement again (i.e., the version that takes
two integer arguments) and supply ResultSet.CONCUR_UPDATABLE as the
Search WWH ::




Custom Search