Public void insert () {int autoinckeyfromapi =-1; // Step 1: Define autoinckeyfromapi to receive the value of ID; autoinckeyfromapi connection conn = dbconnectionmanager. getconnection (); preparedstatement PS = NULL; resultset rs = NULL; string SQL = NULL; SQL = "insert into tab_tsminfo values ()"; logger. debug (SQL); try {PS = Conn. preparestatement (SQL);/** add statement. return_generated_keys. Otherwise, an error is returned: * Java. SQL. sqlexception: generat Ed keys not requested. you need to * specify statement. return_generated_keys to * statement.exe cuteupdate () or connection. preparestatement (). * Put PS = conn on the Internet. preparestatement (SQL, statement. return_generated_keys); * However, if I try to put it in this line, an error will still be reported. If I put it in the next line, no error will be reported. I don't know why. */Ps.exe cuteupdate (SQL, statement. return_generated_keys); RS = ps. getgeneratedkeys (); If (RS. next () {system. out. print (RS. getint (1); // obtain the ID autoinckeyfromapi = rs of the inserted row. getint (1);} Rs. close (); RS = NULL; PS. close (); PS = NULL;} catch (sqlexception e) {// todo auto-generated Catch Block logger. debug (E. tostring ();} finally {If (RS! = NULL) {try {Rs. Close () ;}catch (exception e) {e. printstacktrace () ;}} if (PS! = NULL) {try {ps. Close () ;}catch (exception e) {e. printstacktrace () ;}} dbconnectionmanager. freeconnection (conn );}