MYBATIS 批量update 报错的问题 ?报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

MYBATIS 批量update 报错的问题 ?报错

爱吃鱼的程序员 2020-06-23 14:00:54 48

批量update,很简单的sql语句,可是一直在报错。不知道为什么,求助!!!

close="" separator=";">
update student_point_level s
set s.score = #{item.score}
where s.id = #{item.id}


按照打印出来的sql,贴到front里运行的也都是对的....

Error 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 'update student_point_level s

        set s.score = 16
        where s.id = 19' at line 7

The error may involve com.supert.st.dao.StudentPointLevelMapper.updateStudentPointLevelBatch-Inline

The error occurred while setting parameters

SQL: update student_point_level s set s.score = ? where s.id = ? ; update student_point_level s set s.score = ? where s.id = ?

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 'update student_point_level s

        set s.score = 16
        where s.id = 19' at line 7

; bad SQL grammar []; nested exception is 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 'update student_point_level s
set s.score = 16
where s.id = 19' at line 7

SQL 关系型数据库 MySQL Java 数据库连接 mybatis
分享到
取消 提交回答
全部回答(1)
  • 爱吃鱼的程序员
    2020-06-23 14:01:11

    经过朋友的帮助,此问题已经解决。
    参考:http://www.cnblogs.com/hyq0002013/p/6077847.html

    把你的xml里面的sql全部贴上来看看

    <?xmlversion="1.0"encoding="UTF-8"?>
    <!DOCTYPEmapperPUBLIC"-//mybatis.org//DTDMapper3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">







    <updateid="updateStudentPointLevelBatch"parameterType="java.util.List"><foreachcollection="list"item="item"index="index"open=""close=";"separator=";">updatestudent_point_levelssets.score=#{item.score}wheres.id=#{item.id}</foreach></update><insertid="insertStudentPointLevelBatch">insertintoSTUDENT_POINT_LEVEL(POINT_ID,STUDENT_ID,SCORE,DATETIME)values<foreachcollection="list"item="item"index="index"separator=",">(#{item.pointId},#{item.studentId},#{item.score},now())</foreach></insert>

    0 0
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题
推荐课程