Re: preparedStatement.getGeneratedKeys() exception.
Posted by: Mark Matthews
Date: November 05, 2004 09:39AM


I guess I'm very confused as to why you think getGeneratedKeys() would return an updatable result set, and even if it did, why you'd want to update it.

There's two ways to update a row, either do it explicitly with your SQL (and use getGeneratedKeys() to find out what the AUTO_INCREMENT column's value was), which you can use a prepared statement to do, or you can issue a query that SELECTs from the table you want to update, and use updatable result sets, move to the insert row, set all the values except the one for the AUTO_INCREMENT column, call ResultSet.insertRow(), and the driver will put the value of the AUTO_INCREMENT column into the new row, which you can get using your standard ResultSet.getInt().

Maybe it would be clearer if you explained what you were trying to do, rather than sending your code.


Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.