我没有从 mysql 获取自动生成的密钥
String query="insert into course(subject,board,standard,course_code)values(?,?,?,?)";
st1 = con.prepareStatement(query,Statement.RETURN_GENERATED_KEYS);
st1.setString(1, sub);
st1.setString(2, board);
st1.setString(3, std);
st1.setString(4, course);
rs1 = st1.getGeneratedKeys();
if (rs1.next()){
cid=rs1.getInt(1);
}
System.out.println("2>>>>>>>>" + cid+" "+rs1);
输出:
2>>>>>>>>0 com.mysql.jdbc.JDBC4ResultSet@1b04d3d