利用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 ? ");
代码如下:
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 ? ");
相关文章推荐
- 插入mysql语句报错:1064 - 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
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio
- 报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL
- asp.net mysql无法查询中文;You have an error in your SQL syntax; check the manual that corresponds to
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
- Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL se
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- 错误信息:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ve
- SQL Error: 1064, SQLState: 42000 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ve
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL 完美解决
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
- MySql 执行语句错误 Err] 1064 - 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
- Mybatis报错(二)You have an error in your SQL syntax; check the manual that corresponds to your MySQL se
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server