如何解决mysqlsyntaxerrorexception异常?

wgeznvg7  于 2021-06-21  发布在  Mysql
关注(0)|答案(2)|浏览(424)

当我创建updatejspmysql时,我不断得到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+"'");
u5rb5r59

u5rb5r591#

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+"'");
zu0ti5jz

zu0ti5jz2#

你有多余的钱 , 就在之前 WHERE 你以前也少了一个 EMAIL .

"UPDATE signup SET id_login=?, name_cust=?, password=?, email=?, no_phone=? WHERE id_user=?"

另外,你应该使用 PreparedStatement ,以避免任何sql注入。

相关问题