您的位置:首页 > 数据库 > MySQL

利用Mysql进行update时,出现You have an error in your SQL syntax check the manual that corresponds to your My

2012-04-12 09:45 876 查看
总是出现You have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax ...... at line 1错误。

代码如下:

ps = conn.prepareStatement("update admin set aid = ?,username = ?,password = ?,password2 = ?"

+ "where aid like ? ");

ps.setInt(1,admin.getAid());

ps.setString(2, admin.getUsername());

ps.setString(3, admin.getPassword());

ps.setString(4, admin.getPassword2());

ps.setInt(5, aid);

这段代码没有什么大问题,就是在update的语句中少了个空格!!!

在关键字where后面少了个空格,导致where和参数password2的值连在了一起,出现语法错误。

正确的代码是:

ps = conn.prepareStatement("update admin set aid = ?,username = ?,password = ?,password2 = ?"

+ " where aid like ? ");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐