项目场景:
提示:mybatis批量update失败,mysql数据库
问题描述
在xml中编写sql格式为:
<update id="updateBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update student_info
<set>
name= #{item.maxDegree,jdbcType=VARCHAR},
sex= #{item.minDegree,jdbcType=INTEGER},
address= #{item.degree,jdbcType=VARCHAR}
</set>
<where>
id = #{item.id,jdbcType=INTEGER}
</where>
</foreach>
</update>
原因分析:
mysql数据库连接参数有问题:添加allowMultiQueries=true
解决方案:
提示:设置配置文件的连接参数 jdbc-url
jdbc-url: jdbc:mysql://127.0.0.1:3306/kwzd?serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE&allowMultiQueries=true