postgresql批量新增数据时,批量插入的数据量太大了,造成了IO异常

只能把这么多数据先进行分割,再批量插入,但是感觉这种方式不是最优解,先暂时顶着,具体List分割方式如下:

package cn.ucmed.otaka.healthcare.cloud.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map; public class PartitionArray<T> { public Map<Integer, List<T>> partition(List<T> tArray, int capacity) {
if (tArray.isEmpty() || capacity < 1) {
return null;
}
Map<Integer, List<T>> result = new HashMap<>(); int size = tArray.size();
int count = ((Double) Math.ceil(size * 1.0 / capacity)).intValue(); for (int i = 0; i < count; i++) {
int end = capacity * (i + 1);
if (end > size) end = size;
result.put(i, tArray.subList(capacity * i, end));
}
return result;
}
}

原先批量调用的地方做个处理:

        try {
PartitionArray<MDynamicFuncReleaseHistory> partitionArray = new PartitionArray<>();
Map<Integer, List<MDynamicFuncReleaseHistory>> batchList = partitionArray.partition(releaseHistoryList, INSERT_CAPACITY);
batchList.forEach((k, v) -> {
mDynamicFuncReleaseHistoryMapper.batchInsert(v);
});
} catch (Exception e) {
log.error(e.getMessage());
throw new BusinessException(500, "新增MDynamicFuncReleaseHistory失败");
}

PSQLException: An I/O error occurred while sending to the backend.的更多相关文章

  1. 网站错误记录:A transport-level error has occurred when sending the request to the server.

    今天查看公司项目的日志文件,发现有这个错误:A transport-level error has occurred when sending the request to the server. 感 ...

  2. "A transport-level error has occurred when sending the request to the server,指定的网络名不在可用"的解决办法

    项目在外网服务器上运行的时候,遇到一个异常:"A transport-level error has occurred when sending the request to the ser ...

  3. "A transport-level error has occurred when sending the request to the server"的解决办法

    http://blog.csdn.net/luckeryin/article/details/4337457 最近在做项目时,遇到一个随机发生的异常:"A transport-level e ...

  4. xamarin IOS 报错处理: an error occurred on client Build420719 while

    xamarin IOS 开发时如果报错如下: an error occurred on client Build420719 while...... 出现如下问题时,可能是1.丢失文件2.没有包括在项 ...

  5. An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题

    有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...

  6. Eclipse启动时发生An internal error occurred during: "Initializing Java Tooling".错误的解决方法

    问题描述: Eclipse启动时发生An internal error occurred during: "Initializing JavaTooling".错误的解决方法 解决 ...

  7. ORA-00604: error occurred at recursive SQL level 1

    在测试环境中使用某个账号ESCMOWNER对数据库进行ALTER操作时,老是报如下错误: ORA-00604: error occurred at recursive SQL level 1 ORA- ...

  8. 关于装完系统出现a disk read error occurred的解决方法

    今天偶遇一台老电脑,很久都没有用了,而且只有几百兆的内存,160G的硬盘,无奈只好装XP系统,GHOST完之后,开机发现出现a disk read error occurred的错误,但是用U盘引导可 ...

  9. An error occurred while collecting items to be installed

    安装的插件:Activiti 在Eclipse安装插件时,报以下错误: An error occurred while collecting items to be installed session ...

随机推荐

  1. Spring Security OAuth2.0 - AuthorizationServer和ResourceServer分离

    <Spring Security实现OAuth2.0授权服务 - 基础版>和<Spring Security实现OAuth2.0授权服务 - 进阶版>两篇文章中介绍如何搭建OA ...

  2. Json提取器。

  3. 2019 途牛旅游网java面试笔试题 (含面试题解析)

      本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.途牛旅游网等公司offer,岗位是Java后端开发,因为发展原因最终选择去了途牛旅游网,入职一年时间了,也成为 ...

  4. 基于Druid数据库连接池的DBUtil工具类

    工具类 DruidUtil.java package com.zzuli.util; import com.alibaba.druid.pool.DruidDataSourceFactory; imp ...

  5. js学习之数据结构和算法

    js中的数据结构 1.列表 待办事项列表.购物清单.最佳十名榜单等等. 适用: 1)数据结构较为简单, 2)不需要在一个长序列中查找元素,或者对其进行排序 2.栈 一摞盘子 ----- 添加删除只能从 ...

  6. Android 系统自带图片裁剪功能(适配7.0、8.0、对了还有小米手机)

    前段时间写了如何获取相册和拍照之后的照片并且进行显示和上传,这一次是如何进行圆形图像制作,经常看我写的笔记的人会知道,我很懒.那么我就懒的自定义了,目前需求就用原生的就好了,大神的轮子,我会在后面进行 ...

  7. select用法 多并发处理

    select默认最大检查套接口数量是1024,有定义 #define __NFDBITS (8 * sizeof(unsigned long)) #define __FD_SETSIZE 1024 # ...

  8. Linux系统密码复杂度安全配置

    密码有效期控制 在文件/etc/login.defs中进行设置,如下参数 PASS_MAX_DAYS 180 #密码最长过期天数 PASS_MIN_DAYS 30 #密码最小过期天数 PASS_MIN ...

  9. Odoo中的ORM API(模型数据增删改查)

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826214.html 一:增 1:create():返回新创建的记录对象 self.create({'na ...

  10. cobbler部署错误总结

    web 报错500 Internal Server Error解决方案 在安装使用Cobbler web界面的时候提示HTTP 500错误,也就是服务器内部错误,检查防火墙和selinux都是为关闭状 ...