mysql中插入语句返回自增长操作
String insertPurviewRoleSql = "insert into purview_role(model_sg, operation_sg, role_id) values(?, ?, ?)";//定义sql语句
PreparedStatement pstatmInsertSystemPurview = conn.prepareStatement(insertSystemPurviewSql,PreparedStatement.RETURN_GENERATED_KEYS);//返回类型
pstatmInsertSystemPurview.setString(1, r.getName());//r是一对象
pstatmInsertSystemPurview.execute();//执行插入
ResultSet rs = pstatmInsertSystemPurview.getGeneratedKeys();//获得带有返回值的resultset
rs.next();
int roleid = rs.getInt(1);//拿到id