preparedment的execute报错You have an error in your SQL syntax; check the...报错问题
来源:互联网 发布:回转企鹅罐 知乎 编辑:程序博客网 时间:2024/04/30 07:23
PreparedStatement preStmt = conn.prepareStatement(sql);preStmt.setString(1, user.getUname());preStmt.setString(2, user.getUpass());int i = preStmt.executeUpdate(sql); //运行到这句的时候总是出错
报错信息: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
总是纠结sql语句是否有错,但是在MySQL上运行时正常的。其实executeUpdate()是不带参数的才能正常运行。也有带参数的一个方法,所以编译不会错。
两种方法的区别是:
executeQuery()是PreparedStatement接口中定义的方法。
而executeQuery(sql)是statement中的方法,两者是不同的。
所以改成 int i = preStmt.executeUpdate(); 就不会报错了
- preparedment的execute报错You have an error in your SQL syntax; check the...报错问题
- DbVisualizer报错You have an error in your SQL syntax; check the manual that corresponds to your MySQL
- mysql建立数据库报错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的问题
- 连接数据库报“You have an error in your SQL syntax”异常的解决
- hibernate报错You have an error in your SQL syntax; ......near 'type=InnoDB' at line 7
- You have an error in your SQL syntax; check the manual that corresponds
- [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds...
- 1064 - You have an error in your SQL syntax; check the manual that correspon解决办法
- You have an error in your SQL syntax; check the manual that
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
- 使用CCHttpClient进行cocos2d-x网络编程
- 2013 我要不断积累 心智、技能、经验
- js的this指针
- c++初始化列表
- JDBC
- preparedment的execute报错You have an error in your SQL syntax; check the...报错问题
- @synthesize a=_a
- IAR的一个编译错误Error[e27]: Entry "GenericApp_Init::?relay" in module Coordinator
- 《程序员的第一年》---------- 消息队列与Cookie相关整理
- spring 注解模式 详解
- 指针资料整理
- 一篇-蜘蛛天天爬,但是就是不收录-的帖子
- Minifilter 优点介绍
- SQL数据库查询语句