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. 由一个空工程改为SpringBoot工程

    1.先创建一个空的工程,创建springboot 工程  必须继承spring-boot-stater-parent 2.导入依赖 <parent> <groupId>org. ...

  2. 关于UDP协议

    UDP协议的特点. 1.UDP是一个无连接协议,传输数据之前接收端和发送端之间不建立连接. 想传输数据的时候就抓取数据扔出去,不监控是否被正确和全面的接受到. 2.因为不需要建立连接,也就不需要维护连 ...

  3. 【转载】使用宝塔Linux面板功能查看服务器CPU使用率

    运维过阿里云服务器或者腾讯云服务器的运维人员都知道,针对耗资源以及高并发的应用,很多时候我们需要关注云服务器的资源利用率情况,如最近一段时间内CPU的使用率.内存占用率等情况信息.阿里云和腾讯云官方后 ...

  4. 鼠标按下改变RelativeLayout背景颜色,松开变回

    在drawable下创建bg.xml文件 <?xml version="1.0" encoding="utf-8"?> <selector x ...

  5. Socket-网络服务提供的一种机制

    网络编程 网络通信的要素 Ip,端口,协议(tcp/udp) 127.0.0.1 本机地址   默认主机名:localhost   端口号:用于标识进程的逻辑地址. 有效端口:0-65535   其中 ...

  6. Unity编辑器扩展中,使用Unity自带的GUIStyle

    在进行编辑器扩展时,创建组件的方法一般都会提供GUIStyle参数,可以让我们自定义样式.修改背景图,字体大小,颜色等等. 比如,创建Button组件的方法:public static bool Bu ...

  7. kbmmw 中的Boyer-Moore算法

    kbmmw 5.10 版本中实现了一个非常好用的字符串搜索算法,即Boyer-Moore算法. 在用于查找子字符串的算法当中,BM(Boyer-Moore)算法是目前被认为最高效的字符串搜索算法, 它 ...

  8. C#-Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}

    异常信息如下 捕获到执行这句时异常: Excel.Application ep = new Excel.ApplicationClass(); Retrieving the COM class fac ...

  9. Prometheus学习笔记(5)Grafana可视化展示

    目录 一.Grafana安装和启动 二.配置数据源 三.配置dashboard 四.配置grafana告警 一.Grafana安装和启动 Grafana支持查询Prometheus.从Grafana ...

  10. windows+jenkins+springboot自动构建并后台执行jar

    本文只讲述如何在windows环境下,搭建jenkins并使用,至于概念的东西请自行百度. 好了,直入主题,本人使用 jenkins.war 包进行部署,我们需要准备如下几个: openjdk8    ...