How do I get a id
of an element just inserted in the Database in Java? Something like: mysql_insert_id()
no PHP
.
How do I get a id
of an element just inserted in the Database in Java? Something like: mysql_insert_id()
no PHP
.
Within a transaction
, shortly after inserting into the database and before performing commit
, you can SELECT id FROM tabela WHERE ROWNUM = 1 ORDER BY id DESC
(SQL for Oracle). This query will return the last id
inserted.
SQL may vary by your bank, but the idea is that.