The ResultSet interface contains a collection of update methods for updating the data of a result set.
As with the get methods, there are two update methods for each data type:
· One that takes in a column name.
· One that takes in a column index.
For example, to update a String column of the current row of a result set, you would use one of the following updateString() methods:
S.N.
|
Methods & Description
|
1
|
public void updateString(int columnIndex, String s) throws SQLException
Changes the String in the specified column to the value of s. |
2
|
public void updateString(String columnName, String s) throws SQLException
Similar to the previous method, except that the column is specified by its name instead of its index. |
There are update methods for the eight primitive data types, as well as String, Object, URL, and the SQL data types in the java.sql package.
Updating a row in the result set changes the columns of the current row in the ResultSet object, but not in the underlying database. To update your changes to the row in the database, you need to invoke one of the following methods.
S.N.
|
Methods & Description
|
1
|
public void updateRow()
Updates the current row by updating the corresponding row in the database. |
2
|
public void deleteRow()
Deletes the current row from the database |
3
|
public void refreshRow()
Refreshes the data in the result set to reflect any recent changes in the database. |
4
|
public void cancelRowUpdates()
Cancels any updates made on the current row. |
5
|
public void insertRow()
Inserts a row into the database. This method can only be invoked when the cursor is pointing to the insert row. |
For a better understanding, I would suggest studying JDBC - Data Types.