With the iSeries™ JDBC drivers, you can change ResultSets by performing several tasks.
The default setting for ResultSets is read only. However, with Java™ Database Connectivity (JDBC) 2.0, the iSeries JDBC drivers provide complete support for updateable ResultSets.
You can refer to ResultSet concurrency on how to update ResultSets.
Update rows
Rows may be updated in a database table through the ResultSet interface. The steps involved in this process are the following:
The database itself is not updated until the second step. Updating columns in a ResultSet without calling the updateRow method does not make any changes to the database.
Planned updates to a row can be thrown away with the cancelUpdates method. Once the updateRow method is called, changes to the database are final and cannot be undone.
Note: The rowUpdated method always returns false as the database does not have a way to point out which rows have been updated. Correspondingly, the updatesAreDetected method returns false.
Delete rows
Rows may be deleted in a database table through the ResultSet interface. The deleteRow method is provided and deletes the current row.
Insert rows
Rows may be inserted into a database table through the ResultSet interface. This process makes use of an "insert row" which applications specifically move the cursor to and build the values they want to insert into the database. The steps involved in this process are as follows:
Support for positioned updates
Besides the method for updating the database through a ResultSet, SQL statements can be used to issue positioned updates. This support relies on using named cursors. JDBC provides the setCursorName method from Statement and the getCursorName method from ResultSet to provide access to these values.
Two DatabaseMetaData methods, supportsPositionedUpdated and supportsPositionedDelete, both return true as this feature is supported with the native JDBC driver.
See Example: Change values with a statement through another statement's cursor for more information.
See Example: Remove values from a table through another statement's cursor for more information.