关闭

Mybatis使用“<trim prefix="SET" suffixOverrides=",">”出现Cause: java.sql.SQLException:

1127人阅读 评论(0) 收藏 举报
分类:

今天在使用Mybatis时出现错误:

### Error updating database.  Cause: java.sql.SQLException: MYSQL: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 'CHECKNOTPASSREASON='驾驶证未满一年以上;其他原因:qwe' 
		where OID' at line 3
### The error may involve com.zte.ums.ztev.database.dao.drivermgt.DriverMgtDao.modifyDriver-Inline
### The error occurred while setting parameters
### SQL: update BUS_DRIVER    SET CHECKTHROUGH=?    CHECKNOTPASSREASON=?    where OID = ?
### Cause: java.sql.SQLException: MYSQL: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 'CHECKNOTPASSREASON='驾驶证未满一年以上;其他原因:qwe' 
		where OID' at line 3

检查发现是因为:

<if test="driverLicenseScan !=null">DRIVERLICENSESCAN=#{driverLicenseScan},</if>
			<if test="address !=null">ADDRESS=#{address},</if>
			<if test="checkThrough !=null">CHECKTHROUGH=#{checkThrough}</if>
			<if test="checkNotPassReason !=null">CHECKNOTPASSREASON=#{checkNotPassReason}</if>
			<if test="userGrade !=null">USERGRADE=#{userGrade}</if>

中“#{checkThrough}”,“#{userGrade}”和“#{checkNotPassReason}”后面缺少逗号“,”

改为:

<if test="driverLicenseScan !=null">DRIVERLICENSESCAN=#{driverLicenseScan},</if>
			<if test="address !=null">ADDRESS=#{address},</if>
			<if test="checkThrough !=null">CHECKTHROUGH=#{checkThrough},</if>
			<if test="checkNotPassReason !=null">CHECKNOTPASSREASON=#{checkNotPassReason},</if>
			<if test="userGrade !=null">USERGRADE=#{userGrade},</if>
就好了!

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:367524次
    • 积分:2702
    • 等级:
    • 排名:第13342名
    • 原创:52篇
    • 转载:26篇
    • 译文:0篇
    • 评论:27条
    最新评论