- An updatable result set makes it easy to modify the contents of
a database without using SQL commands
- Create a statement
Statement stat = conn.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
- Get a result set
-
String accountQuery =
"SELECT * WHERE Account_Number = " + account;
ResultSet result = stat.executeQuery(accountQuery);
- Get the value from the Balance column
double balance = result.getDouble("Balance");
- Update the balance in the current row, but not in the database
result.updateDouble("Balance", balance + deposit);
- Change the data in the database
result.updateRow()