John4343
asked on
Get last ID after identity insert in Derby DB
I have a table in a Derby database with a column created:
Id int GENERATED ALWAYS AS IDENTITY CONSTRAINT PK PRIMARY KEY
How do I get the id of the last record inserted? I think I need IDENTITY_VAL_LOCAL, but how do I call it from code?
Id int GENERATED ALWAYS AS IDENTITY CONSTRAINT PK PRIMARY KEY
How do I get the id of the last record inserted? I think I need IDENTITY_VAL_LOCAL, but how do I call it from code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
stmt.executeUpdate("INSERT
ResultSet rs = stmt.getGeneratedKeys();
if (rs.next()) {
int autoKey = rs.getInt(1); }
Thanks