mybatis insert into 报错:[misc.go:167] [“syntax error”] [error="line 2 column 15 near “” "]

[misc.go:167] [“syntax error”] [error="line 2 column 15 near “” "]

<insert id="batchInsert">
    insert into dot (mac, account_id, counter,offline,create_time_long,pen_type,page_id,message)
    VALUES
    <foreach collection="list" item="item" separator=",">
        (
        #{item.mac},#{item.accountId},#{item.counter},#{item.offline},#{item.createTimeLong},#{item.penType},#{item.pageId},#{item.message}
        )
    </foreach>
</insert>

你好,

看下 tidb.log 中是否有更详细的信息,
可以是否 ide 追一下,看下是传入的什么值导致的报错

全是这个错误

数据的话是
SQL 查询

收起

复制

"insert into dot (mac, account_id, counter,offline,create_time_long,pen_type,page_id,message)\n        VALUES\n          \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'01000000007100d50000000000500013435a000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'01000000007200d400000000005000142113000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'01000000007300be00000000005000140e30000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'010000000074004600000000004f00146444000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'01000000007500e900000000004f00145d58000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'010000000076009e00000000004f0015590c000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471278,1,1602817489339,6,16383,'020000000078000000000000004f0015590c000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471283,1,1602817489339,6,16383,'00000000007900d400000000005300132e1a000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471283,1,1602817489339,6,16383,'01000000007a00d400000000005300132e1a000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471283,1,1602817489339,6,16383,'01000000007b00d400000000005300132b13000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471283,1,1602817489339,6,16383,'01000000007c00d400000000005300132a0c000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471283,1,1602817489339,6,16383,'01000000007d00d50000000000530013280d000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000007e00d500000000005300132a1d000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000007f00d600000000005300132b28000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000008000d600000000005300133753000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000008100d70000000000530014420e000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000008200d700000000005300144226000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000008300d800000000005300145234000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000008400d800000000005300145633000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471286,1,1602817489339,6,16383,'01000000008500d800000000005300145a2e000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'01000000008600d80000000000540014021d000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'01000000008700d80000000000540013223a000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'01000000008800d700000000005400132d1b000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'010000000089009900000000005400123360000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'01000000008a005c00000000005400123d4e000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'01000000008b001f00000000005400124744000001752f5df9bb000001752f5df9bb')\n         , \n            ('123400000781',0,29471290,1,1602817489339,6,16383,'02000000008d000000000000005400124744000001752f5df9bb000001752f5df9bb')\n         , \n        "(len :22744);

是Java用的Mybatis 批量写入, 不知道为什么会有\n的出现

同代码在 mysql 会有问题吗/

不会出现这个问题

tidb 是什么版本,mybatis 目前社区好像没有这个问题,追下代码看下哪里传错了?

v4.0.7, 我看到这个错误我也很迷

每分钟的插入量在1000W+往上

有 insert 执行成功的吗,可以登录到机器上查一下 tidb.log,应该有打印出来报错的 sql,可以手动执行下试试