So I'm normally an avid Oracle user, where I would use a transaction involving a SEQUENCE to solve this problem, but at the moment I need to use MySQL for my current project. Say I've got a table setup like so: TABLE_NAME --------------------- Table_ID INT PRIMARY KEY AUTO_INCREMENT Field VARCHAR(10) Now, in my application code, say I have a method like so: public int addRow(String data) { db.query("INSERT INTO TABLE_NAME (Field) VALUES (" + data + ")"); return ?????; } Code (markup): I need this method to return the ID/primary key of the newly added row, which is determined by the database by using AUTO_INCREMENT. Under Oracle, I could just make a transaction, lock the table, lock the sequence, insert the row, return the sequences current value... However, I am not sure of a way to do this under MySQL?