数据库更新数据,SQL一直报异常: `updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExcept

数据库更新数据,SQL一直报异常: updating database. Cause: 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 'where userFileId = 'CAD1681971589000'' at line 13

数据库更新数据,SQL一直报异常: `updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExcept_第1张图片

检查SQL语句

<update id="updateFileInfo" parameterType="com.vanjian.entity.FileInfo">
    update ourbim_user_caddoc
    set
    <if test="fileName != null">
        fileName = #{fileName},
    </if>
    <if test="extand != null">
        extand = #{extand},
    </if>
    <if test="filePath != null">
        filePath=#{filePath},
    </if>
    <if test="addTime != null">
        addTime = #{addTime},
    </if>
    where userFileId = #{userFileId}
</update>

检查后发现是SQL语句写错了,set这里要使用标签,修改后正常。

<update id="updateFileInfo" parameterType="com.vanjian.entity.FileInfo">
    update ourbim_user_caddoc
    <set>
    <if test="fileName != null">
        fileName = #{fileName},
    </if>
    <if test="extand != null">
        extand = #{extand},
    </if>
    <if test="filePath != null">
        filePath=#{filePath},
    </if>
    <if test="addTime != null">
        addTime = #{addTime},
    </if>
    </set>
    where userFileId = #{userFileId}
</update>

一定要细心再细心!!!

你可能感兴趣的:(Bug记录笔记,数据库,java,sql)