I have a table, say Users with an auto-incremented primary key of type BIGINT. 
In Java, I'm looking to
- insert a row to Users
- return the key of that row inserted.
I tried the following without much expectations since the key field of Users is Long and executeBatch() is returning an integer array. 
String query2 = "INSERT INTO Users (name, status) VALUES (?, ?); "
                    + "SELECT LAST_INSERT_ID();";
    // ... code deleted for clarity
int [] tmp = pStat.executeBatch();
The array returned out of this code is empty.
How to do this in MySQL?
I've seen Get the new record primary key ID from mysql insert query? and some other relevant discussions.
 
     
    