I just tried the "JDBC - Updating a Result Set Example&

A forum to discuss Java programming related issues and concerns.
no avatar
tutorialspoint
Site Admin
 
Posts: 144
Joined: Fri Apr 27, 2007 6:52 pm

I just tried the "JDBC - Updating a Result Set Example&

by tutorialspoint » Sat Jan 26, 2013 3:15 am

It bombs out at

Code:
rs.updateDouble( "age", newAge );


throwing:
Code:
com.mysql.jdbc.NotUpdatable: Result Set not updatable (referenced table has no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
at com.mysql.jdbc.UpdatableResultSet.generateStatements(UpdatableResultSet.java:621)
at com.mysql.jdbc.UpdatableResultSet.syncUpdate(UpdatableResultSet.java:1530)
at com.mysql.jdbc.UpdatableResultSet.updateDouble(UpdatableResultSet.java:2056)
at com.mysql.jdbc.UpdatableResultSet.updateDouble(UpdatableResultSet.java:2084)

no avatar
hbquikcomjamesl
 
Posts: 1
Joined: Sat Jan 26, 2013 1:53 am

»

by hbquikcomjamesl » Sat Jan 26, 2013 3:36 am

(The above was posted on my behalf, after my own attempt somehow false-positived the spam-detector)

At any rate, I was eventually able to stick a primary key into the database (if the JDBC tutorial mentions anything about that, it's buried), after a fair amount of digging through the docs for both MySQL and SequelPro (you'd think they'd have been a bit more forward about how to do something so essential), and once I did, the tutorial worked just fine.

I wonder if I'm going to find the same situation when I go through the whole tutorial again with DB2/400 (a database engine that, unlike MySQL, does recognize the concept of RRNs).
--
James H. H. Lampert

no avatar
Aries86
 
Posts: 1
Joined: Fri May 17, 2013 2:09 am

Re: I just tried the "JDBC - Updating a Result Set Example&

by Aries86 » Fri May 17, 2013 2:19 am

Thanks. Figured out I was trying to get a ResultSet from the update results.. Code fixed now to use getMoreResults(), and wait for it to be true :)

Return to JAVA Lobby