Announcement Announcement Module
Collapse
No announcement yet.
Last inserted row's id Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Last inserted row's id

    Hello,

    I have a mysql question related to java. I have a database with integer id (auto incremented). In php we have a function called mysql_insert_id() which gives us the last inserted record's id. Do we have a function in jdbc which directly gives us the last id or do we have to execute anothre query for that (like --> "SELECT MAX(id) FROM table_name") ?

    Thanks.

    Faruk Kuscan

  • #2
    Hello

    For this kind of question at least do a research on Google if mysql_insert_id() is applyied with Java JDBC

    "SELECT MAX(id) FROM table_name" is valid of course, consider use Spring JdbcTemplate instead, BTW consider an important control about transactions to get really the last id if many threads or users are working concurrently in such table

    Comment

    Working...
    X