You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
来源:互联网 发布:linux23端口 编辑:程序博客网 时间:2024/04/26 14:42
遇到一问题,sql语句老是报错:Caused by: 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 syntax to use near 'workNumber = '10521'' at line 13
当时调用的mybatis sql语句是这样的:<update id="doUpdatemessage" parameterType="com.linkdata.domain.Admin" >
update admin
<set >
<if test="threedepartment != null" >
threeDepartment = #{threedepartment,jdbcType=VARCHAR},
</if>
<if test="twodepartment != null" >
twoDepartment = #{twodepartment,jdbcType=VARCHAR},
</if>
<if test="telephone != null" >
telephone = #{telephone,jdbcType=VARCHAR},
</if>
<if test="email != null" >
email = #{email,jdbcType=VARCHAR},
</if>
</set>
where
adminName = #{adminname,jdbcType=VARCHAR} and
workNumber = #{worknumber,jdbcType=VARCHAR}
</update>
而这句sql语句单单拿到数据库中去修改完全没有问题,在网上查到这种错误可能是因为关键字造成的。他人就有过字段名为“desc”与排序的“DESC”冲突导致这种错误。
而我的错误“workNumber = '10521” 完全跟关键字搭不上边啊。
突然发现错误语句中有这样一句话:The error may involve com.linkdata.mapper.AdminMapper.selectByCondition-Inline
“selectByCondition” 这是我的另一个查询语句。我就赶快查看这个查询语句,结果:
<select id="selectByCondition" resultMap="BaseResultMap"
parameterType="com.linkdata.domain.Admin">
select
<include refid="Base_Column_List" />
from admin
where 1 = 1
<if test="adminname != null">
and adminName = #{adminname,jdbcType=VARCHAR}
</if>
<if test="password != null">
and password = #{password,jdbcType=VARCHAR}
</if>
<if test="worknumber != null" >
workNumber = #{worknumber,jdbcType=VARCHAR}
</if>
</select>
在这个查询中我在末尾的条件“workNumber = #{worknumber,jdbcType=VARCHAR}” 中忘记写“and” 所以一直报的。
也因为我的代码报错的时候调用的是“doUpdatemessage”而使我忽视了对其他语句的检查。
此时我才又想起来,mybatis对sql调用的时候,并不是仅仅检索自己调用的那条sql语句,其他语句的错误同样也会反馈出来。
又是一次教训。
- 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
- 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
- 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
- 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
- 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
- ERROR: 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 for the right syntax to use
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
- 黑马程序员 _ java基础 _ 之集合类TreeSet
- android实现跑马灯效果(可以实现两个以上跑马灯)
- Mobile first! Wijmo 5 + Ionic Framework之:费用跟踪 App
- inner join on, left join on, right join on
- mondrian中用mdx计算父级百分比和整体百分比
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- 航班查询接口接口
- Deep Learning(深度学习) caffe模型 特征提取 (windows/linux)
- 网管“北向接口”与“南向接口”
- java 利用 poi 生成 Excel文件的例子
- const 学习小记
- UIViewContentMode
- 社交网络——新一代数据挖掘的金矿
- 神器级IDE----IntelliJ IDEA