### Error updating database-----指数据库database update错误. Cause: java.sql.SQLSyntaxErrorException--sql语法错误: 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 '> = '2022-11-01 00:00:00', status = 0, remark = '', ' at line 6 ------这大概使错的位置### The error may exist(可能存在) in file [G:\2022.12.5scalary\RuoYi-master\jh-product\target\classes\mapper\jhproduct\TAttendRecordMapper.xml] ### The error may involve com.jhsoft.product.record.mapper.TAttendRecordMapper.updateTAttendRecord-Inline ### The error occurred while setting parameters(设置参数时出错) ### SQL: update t_attend_record SET year = ?, month = ?, day = ?, user_id = ?, att_time > = ?, status = ?, remark = ?, section = ?, type = ? where id = ? ### Cause: java.sql.SQLSyntaxErrorException: 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 '> = '2022-11-01 00:00:00', status = 0, remark = '', ' at line 6 ;(查看与您的MySQL服务器版本对应的手册,了解在第6行的'>='2022-11-01 00:00:00',status=0,remark='','附近使用的正确语法;) bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 '> = '2022-11-01 00:00:00', status = 0, remark = '', ' at line 6
由上面给出的问题可知,问题出错文件大概在
mapper\jhproduct\TAttendRecordMapper.xml
文件内出错可能在:
near '> = '2022-11-01 00:00:00', status = 0, remark = '', ' at line 6 ------这大概使错的位置
出错原因,报的错误为:
SQLSyntaxErrorException--sql语法错误
The error occurred while setting parameters(设置参数时出错)
然后我们看一下,mapper.xml位置的代码:,上面说是第6行,》=2022.........
//>是>的意思
<if test="attTime != null">att_time > = #{attTime},</if>就是这句,attTime这个字段在这指的就是时间,然后我们开始分析,
我们是修改语句,不是查询语句,所以改任何字段只需要把新的值赋给字段就可以,而这里是>=
,这个在select中是查询条件,在update中不需要这个条件,只需要把>号去掉,只保留=号即可
<update id="updateTAttendRecord" parameterType="TAttendRecord"> update t_attend_record 1. <trim prefix="SET" suffixOverrides=","> 2. <if test="year != null">year = #{year},</if> 3. <if test="month != null">month = #{month},</if> 4. <if test="day != null">day = #{day},</if> 5. <if test="userId != null">user_id = #{userId},</if> 6. <if test="attTime != null">att_time > = #{attTime},</if> <if test="status != null">status = #{status},</if> <if test="remark != null">remark = #{remark},</if> <if test="section != null">section = #{section},</if> <if test="type != null">type = #{type},</if> </trim> where id = #{id} </update>