How to get the id of last inserted row using preparedstatement? [duplicate]
问题 This question already has answers here : How to get a value from the last inserted row? [duplicate] (14 answers) Closed 7 years ago . I am using the following code to insert a new row to database, I need to get the id of the last inserted row but when I run the code it shows the following message: SEVERE: java.sql.SQLException: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement(). When I use the