JAVA JDBC – Update Row in ResultSet to Database Table

In this chapter you will learn:

1. How to Update a Row in ResultSet in JDBC?

You can update a row in table using RowSet updateString() and updateRow() method. There are 3 steps while updating a row in rowset.

1. Select row which you want to update. You can select a row using absolute(int rownumber) method.

2. Execute updateString(string column_name, string value) method.

It will update 9th row of PRODUCT column with string value ‘HDMI CABLE’ in RowSet. Remember, this update reflects only rowset and it will not reflect in database table until you use updateRow() method.

3. Execute updateRow() command to make changes in database table.

Update Row in MySQL Database using ResultSet Object

Output

Before Update
Before Update
After Update
After Update

Summary

In this chapter you learn how to update a database table row using JDBC RowSet object. In the next chapter you will learn how to insert a row in database table using JDBC RowSet insertRow() method.


Leave a Reply

Your email address will not be published. Required fields are marked *