Java SQL (h2): What's the best way to retrieve the unique ID of the single item I just inserted into

Posted by Daddy Warbox on Stack Overflow See other posts from Stack Overflow or by Daddy Warbox
Published on 2010-04-15T17:08:36Z Indexed on 2010/04/15 17:13 UTC
Read the original article Hit count: 145

Filed under:
|
|
|
|

My current method is this:

SELECT TOP 1 ID FROM DATAENTRY ORDER BY ID DESC

This assumes the latest inserted item always has the highest unique ID (primary key, autoincrementing). Something smells wrong here.

Alternatives?

© Stack Overflow or respective owner

Related posts about java

Related posts about sql