MyCATApache / Mycat-Server

GNU General Public License v2.0
9.51k stars 3.85k forks source link

mycat执行批量更新时报错 #2856

Open zwei2713 opened 3 years ago

zwei2713 commented 3 years ago

1、bug描述 mycat配置成读写分离,数据源连接mycat,执行批量操作时报错,虽然报语法错,我仔细检查了并且也在sql直接执行都没问题: 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 sale_info set account = 'ST-AU',

      ' at line 8

注意:我数据源不配mycat,直接连数据库,就不会报错 2、版本号 v 1.6.7.6-release-20210908145008 3、操作步骤 1.连接数据源: type: com.alibaba.druid.pool.DruidDataSource password: *** username: kaidu_mt url: jdbc:mysql://*:8066/mt_kaidu?useUnicode=true&characterEncoding=UTF8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8 driver-class-name: com.mysql.cj.jdbc.Driver 2.调用批量更新

<update id="batchUpdate" parameterType="java.util.List">
        <foreach collection="saleInfos" item="item" index="index" separator=";">
            UPDATE sale_info
            <trim prefix="set" suffixOverrides=",">
                <if test="item.account!=null and item.account!=''">
                    account = #{item.account},
                </if>
                <if test="item.sku!=null and item.sku!=''">
                    sku = #{item.sku},
                </if>
            </trim>
            WHERE id = #{item.id}
        </foreach>
    </update>

批量更新调用,通过mycat中间件,就会报错~ 直接jdbc连数据库就不会报

oldRabbitForz commented 3 years ago

你用baomidou的mybatis-plus的 updateBatch,这个不会报错

anson88616425 commented 2 years ago

你用baomidou的mybatis-plus的 updateBatch,这个不会报错

我用的数据库是mysql8.0.21,使用mycat做中间件,使用mybatis-plus3.12还是会报错