3 Replies - 1236 Views - Last Post: 13 February 2011 - 12:01 PM Rate Topic: -----

#1 Tarsus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 06-September 10

JDBC - The result set is not updatable

Posted 12 February 2011 - 07:36 AM

Imm trying to delete rows selected from a table in my database, but I get the exception:-

'The result set is not updatable.'

Statement stmtProjidTwo = con.createStatement();
ResultSet del = stmtProjidTwo.executeQuery("SELECT * FROM cont WHERE employee='" + employeeid + "';");
        while(del.next()){
 	del.deleteRow();
       }



ive checked and employeeid is returns three rows, and so should the rows not be available for deletion? The actual error is occuring at del.deleteRow();

This post has been edited by Tarsus: 12 February 2011 - 07:39 AM


Is This A Good Question/Topic? 0
  • +

Replies To: JDBC - The result set is not updatable

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: JDBC - The result set is not updatable

Posted 12 February 2011 - 08:12 AM

why don't you use a Delete statement instead?
Was This Post Helpful? 0
  • +
  • -

#3 m-e-g-a-z  Icon User is offline

  • Winning
  • member icon


Reputation: 496
  • View blog
  • Posts: 1,453
  • Joined: 19-October 09

Re: JDBC - The result set is not updatable

Posted 12 February 2011 - 08:18 AM

Right, i quickly ran something similar on my database and it will only work if

1. You have a primary key
2. You set the createStatement like this
Statement st = connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);


What the ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE does is that it allows the ResultSet objects to be scrollable and updatable since by default, a ResultSet isn't updatable.
Look at the this for a more detailed description.

This post has been edited by m-e-g-a-z: 12 February 2011 - 08:20 AM

Was This Post Helpful? 2
  • +
  • -

#4 masijade  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 196
  • View blog
  • Posts: 580
  • Joined: 03-April 10

Re: JDBC - The result set is not updatable

Posted 13 February 2011 - 12:01 PM

It is because you haven't creted an updateable ResultSet see the API docs for Connection and take a close look at the varying ways to call createStatement.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1