MySql-You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v
程序员文章站
2022-07-14 10:29:08
...
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
报错原因:MySql语句中具有?,需要用PreparedStatement对象动态设置值,这时如果调用ResultSetMetaData metaData = pstm.getMetaData();就会产生以上错误;
如果SQL语句中没有?,调用ResultSetMetaData metaData = pstm.getMetaData();就不会报错。
注意:
1.返回单条数据时,以下两种均可用:
ResultSet resultSet = pstm.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();// 用于获取列名,
或者:ResultSetMetaData metaData = pstm.getMetaData();// 用于获取列名,
2.若返回多条结果时:只能用如下操作:否则报以上错误
ResultSet resultSet = pstm.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();// 用于获取列名,
上一篇: Freemarker基础
下一篇: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
推荐阅读
-
pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that co
-
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
-
MySql-You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v
-
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
-
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
-
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
-
check the manual that corresponds to your MySQL server version for the right syntax的错误解析,correspondssyntax