Reputation: 3
I keep getting MySQLSyntaxErrorException when I create update jsp mysql.
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+"'");
Upvotes: 0
Views: 48
Reputation: 42
Incorrect syntax in the SQL statement, try this
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+"'");
Upvotes: 0
Reputation: 31417
You have extra ,
just before WHERE
and you are missing one before EMAIL
.
"UPDATE signup SET id_login=?, name_cust=?, password=?, email=?, no_phone=? WHERE id_user=?"
Also, you are supposed to use PreparedStatement
, to avoid any SQL injection.
Upvotes: 2