在写javaweb实验时出现了这个问题:
具体问题如下:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id=4' at line 1
也就是说在sql语句出现错误,在sql语句的第一行的‘id=4’附近。
这时候可以看到这个语句的user_name,age,sex,id并不是一些mysql内部关键字。
在sql语句中更新语句就是:
update tbl_user_info
set user_name=?,age=?,sex=?
where id=?
所以就是在“sex=?”+“ where id=?”加上一个空格就好。
或者