Refreshing a Row in an Updatable Result Set - Java JDBC

Java examples for JDBC:ResultSet

Description

Refreshing a Row in an Updatable Result Set

Demo Code

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {
  public static void main(String[] argv) throws Exception {
    Connection connection = null;
    try {/*from  www  .j a  v  a2s . co  m*/
      // Create an updatable result set
      Statement stmt = connection.createStatement(
          ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");

      // Use the result set...

      // Retrieve the current values of the row from the database
      resultSet.refreshRow();
    } catch (SQLException e) {
      // Could not connect to the database
    }
  }
}

Related Tutorials