mybatis批量update(mysql)

Mapper文件中的写法

<insert id="batchUpdateTjData">
        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
            UPDATE test_table
                SET c_a = #{item.ca},
                     c_b = #{item.cb}
            WHERE id = #{item.id}
        </foreach>

 </insert>

这样写总是报错,调试了很长时间也没找到问题原因

最后找到这里http://my.oschina.net/jsonavaj/blog/265112 找到了答案

 

数据库的链接必须加上但是数据库连接必须加上 allowMultiQueries=true

url="jdbc:mysql://localhost:3306/testDatabase?allowMultiQueries=true" />

 

posted on 2015-07-28 16:24  modprobe  阅读(483)  评论(2编辑  收藏  举报