使用PreparedStatement,出现You have an error in your SQL syntax; check the manual that corresponds to you
来源:互联网 发布:机房网络搭建 编辑:程序博客网 时间:2024/05/17 07:17
PreparedStatement时,出现了错误: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 ‘? AND mstate=?’ at line 1。而且sql语句的占位符与为其赋值的setXXX方法相匹配,并没有错。
经排查,是获得结果集时,多写了参数。ResultSet rSet = pps.executeQuery(sql);
与Statement不同,在创建PreparedStatement时,便为其指定了sql语句,获得结果集时不需要再指定了。而Statement创建时未指定,获得结果集时需要制定。
创建 PreparedStatement 与执行sql语句:
PreparedStatement pps = con.prepareStatement(sql);ResultSet rSet = pps.executeQuery();
创建 Statement与执行sql语句:
Statement statment = con.createStatement();ResultSet rSet = statment.executeQuery(sql);
另外,在使用PreparedStatement时,需要为sql语句中每一个占位符通过setxxx方法赋值,并且其值不能为空。不然会查询不到内容。
阅读全文
0 0
- 使用PreparedStatement,出现You have an error in your SQL syntax; check the manual that corresponds to you
- 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
- 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 M
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your My
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- 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...
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
- python爬虫学习第七天
- 第一章 实用R内置数据进行数据处理--笔记
- HDU-1848-组合博弈
- 割点和桥
- 排序与查找
- 使用PreparedStatement,出现You have an error in your SQL syntax; check the manual that corresponds to you
- 微信小程序录音后上传文件
- 我的博客
- Java NIO与IO的区别
- 利用Cookie记录商品浏览信息
- Vue 由单个复选框引发的联想
- JavaScript---继承之对象冒充(构造函数绑定)
- Java NIO缓冲区(Buffer)的数据存取
- 执行环境及作用域