Sunday, July 3, 2011

Updating Column Values

You update data in a JdbcRowSet object the same way you update data in a ResultSet object.

Assume that the Coffee Break owner wants to raise the price for a pound of Espresso coffee. If the owner knows that Espresso is in the third row of the jdbcRsobject, the code for doing this might look like the following:

jdbcRs.absolute(3);  jdbcRs.updateFloat("PRICE", 10.99f);  jdbcRs.updateRow(); 

The code moves the cursor to the third row and changes the value for the column PRICE to 10.99, and then updates the database with the new price.

Calling the method updateRow updates the database because jdbcRs has maintained its connection to the database. For disconnected RowSet objects, the situation is different.

No comments:

Post a Comment