当我创建update jsp mysql时,我不断收到MySQLSyntaxErrorException。
String id_user = request.getParameter("id_login");
String name_cust = request.getParameter("name_cust");
String password = request.getParameter("password");
String email = request.getParameter("email");
String no_phone = request.getParameter("no_phone");
Statement st = CON.createStatement();
//ResultSet rs;
int i = st.executeUpdate("UPDATE signup SET id_login='"+id_user+"',name_cust='"+name_cust+"', password='"+password+"'email='"+email+"',no_phone='"+no_phone+"', WHERE id_user='"+id_user+"'");
答案 0 :(得分:2)
您在,
之前有额外的WHERE
,而您在EMAIL
之前错过了一个"UPDATE signup SET id_login=?, name_cust=?, password=?, email=?, no_phone=? WHERE id_user=?"
。
PreparedStatement
此外,您应该使用 char original[5];
scanf("%5s", original); // String containing 5 chars
,以避免任何SQL注入。
答案 1 :(得分:0)
SQL语句中的语法不正确,请尝试此
int i = st.executeUpdate("UPDATE signup SET id_login='"+id_user+"',name_cust='"+name_cust+"', password='"+password+"'email='"+email+"',no_phone='"+no_phone+"'WHERE id_user='"+id_user+"'");