ResultSet interface maintains a cursor pointing to move forward and backward direction by passing either TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE in createStatement(int,int) method as well as we can make this object as updatable by.
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
package com.java.session.ninteen;
import java.sql.*;
public class ResultSetInterfaceExample {
static final String DB_URL = "jdbc:mysql://localhost/emp";
static final String USER = "root";
static final String PASS = "PASSWORD";
static final String QUERY = "SELECT id, first, last, age FROM employee";
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = DriverManager.getConnection(DB_URL, USER, PASS);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(QUERY);
rs.absolute(3);
System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3));
} catch (SQLException e) {
e.printStackTrace();
}
try {
conn.close();
stmt.close();
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}