出现的问题
### The error occurred while setting parameters
### SQL: update crawler_ip_all SET auto_table = ?, put_reason = ?, put_user = ?, put_way = ?, createtime = ?, updtime = ? WHERE ip = ? ; update crawler_ip_all SET auto_table = ?, put_reason = ?, put_user = ?, put_way = ?, createtime = ?, updtime = ? WHERE ip = ?
### 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 'update crawler_ip_all
SET auto_table = '1',
' at line 10
; 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 'update crawler_ip_all
SET auto_table = '1',
' at line 10
mybatis 批量更新数据库的mapper
<update id="updateBath" parameterType="java.util.List">
<if test="list!=null">
<foreach collection="list" item="item" index= "index" open="" close="" separator =";">
update crawler_ip_all
<set>
<if test ='null != item.autoTable'> auto_table = #{item.autoTable}, </if>
<if test ='null != item.putReason'> put_reason = #{item.putReason}, </if>
<if test ='null != item.putUser'> put_user = #{item.putUser}, </if>
<if test ='null != item.putWay'> put_way = #{item.putWay}, </if>
<if test ='null != item.createtime'> createtime = #{item.createtime}, </if>
<if test ='null != item.updtime'> updtime = #{item.updtime} </if>
</set>
<where>
ip = #{item.ip}
</where>
</foreach>
</if>
</update>
dao封装的接口
int updateBath(@Param("list") List<CrawlerIPAllDetailBean> crawlerIPAllDetailBeanList);
最后的解决方案是:
的 url上 增加 allowMultiQueries=true 表示允许批量操作