com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; che
出现此种错误,我暂时遇到了两次。 
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的更多相关文章
- org.apache.ibatis.exceptions.PersistenceException:  ### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manu
		这个是sql 语句 错误 仔细检查 SQL语句是否写错了 org.apache.ibatis.exceptions.PersistenceException: ### Error queryi ... 
- 【mybatis】mybatis进行批量更新,报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
		使用mybatis进行批量更新操作: 报错如下: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an erro ... 
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;问题的解决
		哇,时隔两天时间,终于找到这个问题的解决办法,先看问题 这是我最近写的家庭记账本网页版,按顺序输入点击保存,总是弹出添加失败的提示 顺着找原因,把原因锁定在dao层的sql语句上,反复检查,没有找到一 ... 
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL
		1.错误描述 org.hibernate.exception.SQLGrammarException: error executing work at org.hibernate.exception. ... 
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
		Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You ... 
- Spring mvc中junit测试遇到com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException错误怎么解决
		今天遇到图片中的错误,纠结了一下,弄清楚了怎么从控制台中读取错误信息,并修改错误. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: ... 
- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
		### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You h ... 
- Mybatis批量更新报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
		批量更新数据,非常简单的一段代码,硬是报错,插入的数据也能显示出来 List<User> userlist = new ArrayList<User>(); userlist. ... 
- 一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException问题排查过程
		先说结论: 因为在表设计中有一个商品描述字段被设置为desc,但desc是mysql中的关键字,如select id,name,desc,price from product;这条sql语句在查询时的 ... 
随机推荐
- struts2核心和工作原理
			转至:http://blog.csdn.net/laner0515/article/details/27692673 在学习struts2之前,首先我们要明白使用struts2的目的是什么?它能给我们 ... 
- 《程序员代码面试指南》第二章 链表问题 将单链表每K个节点之间逆序
			样例 链表1-2-3-4-5-6-7-8-9-10 K=3 ,结果 3-2-1-6-5-4-9-8-7-10 java代码 /** * @Description:将单链表每K个节点之间逆序 * @Au ... 
- 机器学习相关知识整理系列之一:决策树算法原理及剪枝(ID3,C4.5,CART)
			决策树是一种基本的分类与回归方法.分类决策树是一种描述对实例进行分类的树形结构,决策树由结点和有向边组成.结点由两种类型,内部结点表示一个特征或属性,叶结点表示一个类. 1. 基础知识 熵 在信息学和 ... 
- linux下无线鼠标驱动执行流程
			操作系统: debian 7.4(linux 3.2.54) 硬件: 一个无线鼠标.一个有线鼠标.usb集线器. 从淘宝上花了15块钱买了个无线鼠标,很好奇它的驱动程序是如何执行的. 首先将usb集线 ... 
- POJ 3070 矩阵mob
			. 矩阵高速幂想法与快速幂相同 #include<iostream> #include<cstdio> #include<cstring> #define MOD ... 
- eclipse中使用git技巧总结
			之前一直使用svn,刚使用git还是有些蹩脚,今天总结下在使用git中常用技巧 1. ①.整个版本还原 当需要还原到某个版本时(多文件),操作如下 右击项目-->Team-->Show i ... 
- Mysql的链接超时异常CommunicationsException
			原文是在博客上的:小重合之旅 链接如下:未经过作者同意,这里注明下. http://blog.csdn.net/bluesnail216/article/details/15810119 1,问题现象 ... 
- Eclipse debug neutron-server
			1 首先停掉neutron-server kill neutron-server in screen by ctr-c q-svc 2 cp /usr/local/bin/neutron-server ... 
- linux学习-文件打包与压缩
- Sqoop- sqoop将mysql数据表导入到hive报错
			sqoop将mysql数据表导入到hive报错 [root@ip---- lib]# sqoop import --connect jdbc:mysql://54.223.175.12:3308/gx ... 
