db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: Statement.getGenerateKeys() doesn't work with Derby
Date Wed, 26 Jul 2006 14:01:06 GMT
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 

Did you remember to create the PreparedStatement with the correct 

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,

> Hong

View raw message