Result set update error
java, jdbc
Solution
Reason is you are using `Select` query and trying to perform `Update` operation
ResultSet rs = stmt.executeQuery("select * from EMPLOYEE");
and another point is "SELECT *" makes Resultset as ReadOnly
If you want to perform update operation then you need to specify columns in the Select Query
Problem
I wrote a simple code for scrollable resultset.But it gives me an error. code: ``` import java.sql.*; import java.util.Properties; public class Scrollable_Resultset { public static void main(String[] args) throws Exception{ Properties p = new Properties(); p.put("user", "system"); p.put("password", "password"); DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",p); Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery("select * from EMPLOYEE"); System.out.println("Displaying all the rows of the result set forward"); while(rs.next()) { System.out.println(rs.getInt(1)); System.out.println(rs.getString(2)); System.out.println(rs.getInt(3)); System.out.println("--------------"); }//end of while System.out.println("****************"); System.out.println("Printing resultset in reverse order"); rs.last();//go to last row while(rs.previous()) { System.out.println(rs.getInt(1)); System.out.println(rs.getString(2)); System.out.println(rs.getInt(3)); System.out.println("--------------"); }//end of while System.out.println("****************"); System.out.println("Printing only 1st row"); rs.first(); System.out.println(rs.getInt(1)); System.out.println(rs.getString(2)); System.out.println(rs.getInt(3)); System.out.println("--------------"); System.out.println("****************"); System.out.println("Printing 3rd row of original data set"); System.out.println(rs.getInt(1)); System.out.println(rs.getString(2)); System.out.println(rs.getInt(3)); System.out.println("--------------"); System.out.println("****************"); System.out.print("No of rows before modification: "); rs.last(); System.out.println(rs.getRow()); System.out.println("****************"); System.out.println("Updating 3rd row"); rs.absolute(3); rs.updateInt(1, 999); rs.updateString(2,"John"); rs.updateInt(3, 99000); rs.updateRow(); System.out.println("****************"); System.out.println("Inserting a new row"); rs.moveToInsertRow(); rs.updateInt(1, 99); rs.updateString(2,"Michael"); rs.updateInt(3, 909); rs.insertRow(); System.out.println("Deleting the 6th row"); rs.absolute(6); rs.deleteRow(); System.out.println("****************"); con.close(); } ``` } Error ``` Exception in thread "main" java.sql.SQLException: Invalid operation for read only resultset: updateInt at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java) at oracle.jdbc.driver.BaseResultSet.updateInt(BaseResultSet.java) at jdbc.Scrollable_Resultset.main(Scrollable_Resultset.java:64) ``` It gives error when I try to update data although I have used ResultSet.CONCUR_UPDATABLE. Can any one please let me know what is the reason for the same?