com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; che
2017-12-09 22:53
344 查看
出现此种错误,我暂时遇到了两次。
1 我的字段的名称和数据库的关键字重合。
上图中的desc是默认降序排列的意思。
2 第二次出现的异常是我在重构代码阶段遇到的一个bug.不过我暂时不能理解,虽然解决了错误。
删除操作的代码如下:
或者如下的写法:都是正确的。
但是遇上查询一个结果的时候出现了问题:
修改之后又可以啦;
有点疑惑。
1 我的字段的名称和数据库的关键字重合。
上图中的desc是默认降序排列的意思。
2 第二次出现的异常是我在重构代码阶段遇到的一个bug.不过我暂时不能理解,虽然解决了错误。
删除操作的代码如下:
public void deleteProduct(Long id) { sql = "DELETE FROM t_product WHERE id= ?"; JDBCTemplate.templateDML(sql,id); }
或者如下的写法:都是正确的。
public void deleteProduct(Long id) { sql = "DELETE FROM t_product WHERE id="+id; JDBCTemplate.templateDML(sql); }
但是遇上查询一个结果的时候出现了问题:
public Product getProductById(Long id) { sql="SELECT * FROM t_product WHERE id=?"; List<Product> list = JDBCTemplate.templateDQL(sql,id); return list.size()==1?list.get(0):null; }
修改之后又可以啦;
public Product getProductById(Long id) { sql="SELECT * FROM t_product WHERE id="+id; List<Product> list = JDBCTemplate.templateDQL(sql); return list.size()==1?list.get(0):null; }
有点疑惑。
相关文章推荐
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; che
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; che
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
- 1064 - You have an error in your SQL syntax问题解决
- 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
- mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax; check the manual t
- 报错:[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQ
- org.hibernate.exception.SQLGrammarException: could not inYou have an error in your SQL syntax;完美解决错误
- 错误信息: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
- FAQ(67):java.sql.SQLException: You have an error in your SQL syntax; check the manual that correspon
- mysql数据库的You have an error in your SQL syntax问题
- MySql 使用mysqldump导出 You have an error in your SQL syntax
- 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 versio
- python2.7 pymysql中 pymysql.err.ProgrammingError:1064, You have an error in your SQL syntax;
- 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 for the right syntax to use
- 1064 - You have an error in your SQL syntax; check the manual that correspon解决办法