Hong Ji wrote:
Hello,
I am using a PerparedStatement to insert a record. After the record is inserted (after statement.executeUpdate()), I call aStatement.getGeneratedKeys() to retrieve the generated id of the new record, but it returns a null ResultSet. Is getGeneratedKeys() supposed to work with Derby?

Hello Hong,

Yes, getGeneratedKeys() is supposed to work.
I'm able to retrieve a auto-generated key when doing an INSERT with a PreparedStatement.

Did you remember to create the PreparedStatement with the correct Connection.prepareStatement-method? (Connection.prepareStatement(String,int))

You must tell Derby to return the generated keys, or else you will get an empty ResultSet. Note that Derby does not support the prepareStatement-methods that take an integer or String array.



Hope this helps,
--
Kristian

Hong

Reply via email to