[size=large][size=x-small]最近将学的只是运用一下,在对数据库进行增删改查的时候,后台老是抛出
“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 '?,?,?,?,?,?,?,?,?)' at line 1”这样的异常,后来究其原因发现解决很简单。首先我用的是PreparedStatement 预处理语句 然后在调用更新update的时候,不小心用成了executeUpdate(sql);而这个是Statement中的命令,当然是不行了,该成executeUpdate()即可.[/size][/size]
“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 '?,?,?,?,?,?,?,?,?)' at line 1”这样的异常,后来究其原因发现解决很简单。首先我用的是PreparedStatement 预处理语句 然后在调用更新update的时候,不小心用成了executeUpdate(sql);而这个是Statement中的命令,当然是不行了,该成executeUpdate()即可.[/size][/size]
本文介绍了一个简单的SQL语法错误及其解决方案。作者在使用PreparedStatement预处理语句时,误用了Statement中的executeUpdate(sql)方法,导致出现“You have an error in your SQL syntax...”的异常。正确的做法应该是使用executeUpdate()方法。
2588

被折叠的 条评论
为什么被折叠?



