It looks like Firebird does NOT support getGeneratedKeys() after you perform an insert with an auto_increment column. So I would like to understand how I can get my hands on the generated key after an insert.
1) Do I have to use “insert into users(…) values(…) returning id” and call this through a CallableStatement in order to get the generated ID? How exactly? Do I need to wrap my insert around a “call { … }”
2) Is there some other way of getting the generated id under Firebird, some kind of “select last_id_generated()”. “select max(id) from users” does not count.
3) Is it really true that getGeneratedKeys() is not supported by Firebird JDBC driver? (optional)
Thanks!
It turns out that all you have to do is call the “insert … returning” with executeQuery (from PreparedStatement) instead of executeUpdate. That will return your ResultSet from where you can get the generated id. I never thought that you could call an INSERT with executeQuery. I thought you had to do executeUpdate.