I am inserting records into a database table through plain old JDBC(as this is what the set up is in the project I am working on.. not yet migrated to Hibernate).
here is my table structure
employee (empid int indentity not null, empName);
when I try to insert record through JDBC code
insert into employee(empName) values('something')
it works and a record gets inserted. However I need to get the id against the inserted row. I can try executing a separate select query to get the inserted row but might not get the correct inserted record id if 2 employee names are same.
How do I get the inserted record id using JDBC. I am using preparedStatment.executeUpdate
which returns 0 or 1 based on whether the record is inserted or not.