ResultSet update

In this chapter you will learn:

  1. How to update a ResultSet

Updating a Result Set

The ResultSet interface has methods for updating the data. There are two update methods for each data type:

  • Update by a column name.
  • Update by a column index.

For example

  • public void updateString(int columnIndex, String s)
    Update the String by columnIndex.
  • public void updateString(String columnName, String s)
    Update the String by columnName.

Updating a row in the result set changes in the ResultSet object, but not in the underlying database. To update the database, we have to invoke one of the following methods.

  • public void updateRow()
    Updates the current row in the database.
  • public void deleteRow()
    Deletes the current row from the database
  • public void refreshRow()
    Refreshes the data in the result set to reflect any recent changes in the database.
  • public void cancelRowUpdates()
    Cancels any updates made on the current row.
  • public void insertRow()
    Inserts a row into the database when the cursor is pointing to the insert row.

Next chapter...

What you will learn in the next chapter:

  1. Get the Column Names in a Result Set
Home » Java Tutorial » Statements, ResultSet, Exception, Warning

Statement

    Three types of statements
    Statement interface
    Insert
    Delete records
    Drop a table
    Batch operation

PreparedStatement

    PreparedStatement
    Insert
    Delete
    Update with parameters
    Batch operation
    ParameterMetaData
    Fetch size
    Set null vaue

CallableStatement

    CallableStatement

ResultSet

    ResultSet
    ResultSet Type
    ResultSet Concurrency
    Create a ResultSet
    ResultSet reading
    ResultSet get by column name
    ResultSet get column by index
    ResultSet next row
    ResultSet table row count
    ResultSet navigation
    ResultSet cursor forward and backward
    ResultSet first
    ResultSet last
    ResultSet after last
    ResultSet before first
    ResultSet absolute(2)
    ResultSet absolute(-1)
    ResultSet relative(-2)
    ResultSet relative(-2)
    ResultSet update
    Column Names
    Column count
    Column Characteristics

ResultSetMetaData

    Column Names
    Column count
    Column Characteristics

SQL Exception, SQL Warning

    SQL Exception
    SQLException information
    Chaining SQLExceptions
    Connection Warning
    PreparedStatement SQLWarning
    Statement SQLWarning
    ResultSet warning
    SQLWarning information