What's the best way to get the last inserted id using sqlite from Java?

后端 未结 2 1406
孤街浪徒
孤街浪徒 2020-12-06 01:31

What\'s the best way to get the last inserted id using sqlite from Java? Google is giving me different answers--some say select the last-insert-rowid; others say call statem

2条回答
  •  暖寄归人
    2020-12-06 02:14

    Use getGeneratedKeys() if your JDBC driver supports it. You don't want to muck around trying to get the key yourself after the insert. If your driver does not support getGeneratedKeys() then I would get the next value from the key before the insert.

提交回复
热议问题