Getting Data from a Row in a RowSet Updating a Row in a RowSet

6-8 Oracle Fusion Middleware Programming JDBC for Oracle WebLogic Server

6.4.9 Setting CachedRowSet MetaData

In some cases, you may need to set metadata for the rowset in order to synchronize data changes in the rowset with data in the database. See Section 6.5, RowSet MetaData Settings for Database Updates for more information.

6.4.10 Working with Data in a CachedRowSet

After you populate the cached rowset with rows of data, you can work with the cached data in much the same way as you would work with data in a result set, except that before your changes are made in the database, you must explicitly call acceptChanges .

6.4.10.1 Getting Data from a Row in a RowSet

To get data from a rowset, you use the getXXX methods just as you would with a result set. For example: while rs.next { int id = rs.getInt 1; String fname = rs.getString FIRST_NAME; String mname = rs.getString MIDDLE_NAME; String lname = rs.getString LAST_NAME; }

6.4.10.2 Updating a Row in a RowSet

Data updates typically follow this course of events: 1. Navigate to the row or to an insert row. 2. Change the row with updateXXX methods. 3. Complete the operation with updateRow or insertRow. Note that completing the operation does not synchronize your changes with the database. Changes are made to the rowset only. You must explicitly synchronize your changes by calling acceptChanges. For details, see Section 6.4.11, Synchronizing RowSet Changes with the Database later in this section. When working with a rowset, WebLogic Server internally sets the life cycle stage of the rowset after each operation on the rowset, and then limits further operations you can perform on the rowset based on its current life cycle stage. After you begin modifying a row with update methods, you must complete the operation with updateRow or insertRow before you can work with data in any other rows, including moving the cursor to another row. See Section 6.3, Programming with RowSets for a complete discussion of rowset life cycle stages and operations allowed for each stage. Note: Delimiter identifiers may not be used for column or table names in rowsets. Delimiter identifiers are identifiers that need to be enclosed in double quotation marks when appearing in a SQL statement. They include identifiers that are SQL reserved words e.g., USER , DATE, etc. and names that are not identifiers. A valid identifier must start with a letter and contain only letters, numbers, and underscores. Using RowSets with WebLogic Server 6-9 To update a row, you move the cursor to the row you want to update, call updateXXX methods on individual columns within the row, then call updateRow to complete the operation. For example: rs.first; rs.updateString4, Francis; rs.updateRow;

6.4.10.3 Inserting a Row in a RowSet