The incoming request has too many parameters. The server supports a maximum of 2100 parameters

1.遇到的问题

### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
; uncategorized SQLException; SQL state [S0001]; error code [8003]; The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.

2.官方文档

 根据据中 [SQL Server 的最大容量规范] 中规定,每个用户定义函数的参数个数最大为2100。(SQL Server 的最大容量规范 - SQL Server | Microsoft Learn )

3.解决办法 

我是用mybatisplus批量插入,可以把list分成200条提交一次

  public void batchInsertTask(OutTask task, List<OutlList> outList) {
        List newList = new ArrayList<OcsoutListVo>();
        int pointsDataLimit = 100;
        int maxSize=outList.size() - 1;
        for (int i=0; i<outList.size();i++) {
            OutList clVo= outList.get(i);
            OutListVo vo = new OutListVo();
            vo.setRecordId(clVo.getId());
            vo.setAttempt(task.getRetryCount()); 
            newList.add(vo);
            //载体list达到要求,进行批量操作
            if (pointsDataLimit == newList.size() || i == maxSize) {
                //调用批量插入
                outListMapper.batchInsertOutList(newList, task.getCode());
                //每次批量操作后,清空载体list,等待下次的数据填入
                newList.clear();
            }
        }

4.总结

批量插入还可以引入多线程操作。 

提示语:大成者大累,大智者大忧,无能者无欲无求。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值