使用预准备语句自动递增时出现错误。
我的代码是:
String userid=request.getParameter("userid");
String notes=request.getParameter("notes");
String driver="com.ibm.db2.jcc.DB2Driver";
String url="jdbc:db2://localhost:50000/practice";
String user="ANISH";
String passw="anishAZAD";
Class.forName(driver);
Connection cn=DriverManager.getConnection(url,user,passw);
PreparedStatement ps=cn.prepareStatement("insert into auton(userid,notes) values(?,?)",Statement.RETURN_GENERATED_KEYS);
ps.setString(1,userid);
ps.setString(2,notes);
ps.executeUpdate();
ResultSet r = ps.getGeneratedKeys();
r.next();
int autonincrement = r.getInt(1);
//ps.setInt(1,autonincrement);
ps.executeUpdate();
pw.print("Success");
RequestDispatcher rd=request.getRequestDispatcher("demo.html");
rd.include(request, response);