JDBC安插成功返回当前自增ID

JDBC插入成功返回当前自增ID1:不用自增ID,直接用uuid不存在此问题2:自增ID。mysql数据库Class.forName(com

JDBC插入成功返回当前自增ID
1:不用自增ID,直接用uuid不存在此问题

2:自增ID。mysql数据库

Class.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/testing","root","root");System.out.println(conn);stmt=conn.createStatement(); int row=stmt.executeUpdate ("insert into aa (name) values ('mars')",Statement.RETURN_GENERATED_KEYS); rs = stmt.getGeneratedKeys (); if ( rs.next() ) {    int key = rs.getInt(row);    System.out.println(key); }