java传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确。此 RPC 请求中提供了过多的参数。最多应为 2100

在项目中,我们可能会用mybatis foreach 循环插入, 或者in 参数查询, 如果参数过多超过2100会出现报错,我们解决方式为分批查询或插入。代码如下:

  ArrayList result = new ArrayList<>();
        Integer count = needAddIdOrgPatient.size();

        Integer queryNumOne = count / 15;//循环次数,一次15条

        if (count % 15 != 0) {//有余数循环次数+1
            queryNumOne++;
        }

        Integer num = 0;

        for (int index = 0; index < queryNumOne; index++) {
            List param = CollectionUtil.sub(needAddIdOrgPatient, num, num + 15);
            result.addAll(peisPatientMapper.getByIdOrgPatients(param));
            num = num + 15;
        }

你可能感兴趣的:(java,数学建模,开发语言)