数据库更新数据,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语句

<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>

一定要细心再细心!!!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐