• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rs.updateRow()

 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to update a row in a table using ResultSet.updateRow(), is there any condition like, the table should have a primary key compulsorily.

Because, when i try to update a row in a table which is not having a primary key, i am getting the following exception

"ERROR: java.sql.SQLException: Operation invalid. No primary key for the table
java.sql.SQLException: Operation invalid. No primary key for the table"

please clear it.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cant tell exactly , better you post the part of your code which throws an exception , with DB you are using !

Ahh , Just searched and found a useful link HTH !
[ August 27, 2008: Message edited by: Sagar Rohankar ]
 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code -
----

stmt=con.createStatement(rs.TYPE_SCROLL_SENSITIVE,rs.CONCUR_UPDATABLE);
rs=stmt.executeQuery("select c2 from pkey");

rs.first();
rs.updateInt("c2",999);
rs.updateRow();

Table -
-----

create table pkey(c1 int,c2 int);
 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sagar Rohankar:
Cant tell exactly , better you post the part of your code which throws an exception , with DB you are using !

Ahh , Just searched and found a useful link HTH !

[ August 27, 2008: Message edited by: Sagar Rohankar ]


Hey sagar, thanks for the reply.... that link was very useful...
 
Campbell Ritchie
Sheriff
Posts: 51332
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Vinod" you appear to have missed our naming policy when you logged in; please go to "my profile" "update etc" and correct your displayed name to comply.
We require first name-space-last name not obviously fictitious.

CR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic