PSQLException: An I/O error occurred while sending to the backend.
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.的更多相关文章
- 网站错误记录: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. 感 ...
- "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 ...
- "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 ...
- xamarin IOS 报错处理: an error occurred on client Build420719 while
xamarin IOS 开发时如果报错如下: an error occurred on client Build420719 while...... 出现如下问题时,可能是1.丢失文件2.没有包括在项 ...
- An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题
有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...
- Eclipse启动时发生An internal error occurred during: "Initializing Java Tooling".错误的解决方法
问题描述: Eclipse启动时发生An internal error occurred during: "Initializing JavaTooling".错误的解决方法 解决 ...
- ORA-00604: error occurred at recursive SQL level 1
在测试环境中使用某个账号ESCMOWNER对数据库进行ALTER操作时,老是报如下错误: ORA-00604: error occurred at recursive SQL level 1 ORA- ...
- 关于装完系统出现a disk read error occurred的解决方法
今天偶遇一台老电脑,很久都没有用了,而且只有几百兆的内存,160G的硬盘,无奈只好装XP系统,GHOST完之后,开机发现出现a disk read error occurred的错误,但是用U盘引导可 ...
- An error occurred while collecting items to be installed
安装的插件:Activiti 在Eclipse安装插件时,报以下错误: An error occurred while collecting items to be installed session ...
随机推荐
- Beego 学习笔记11:文件的上传下载
文件的上传和下载 1->文件的上传 文件的上传,采用的是uploadify.js这个插件. 本事例实现的是上传图片文件,其他的文件上传也一样. 2->文件的下载 文件的下载有两个实现的方式 ...
- 学校老师没重点讲的C语言
格式说明由“%”和格式字符组成,如%d%f等.它的作用是将输出的数据转换为指定的格式输出.格式说明总是由“%”字符开始的.不同类型的数据用不同的格式字符. 格式字符有d,o,x,u,c,s,f,e,g ...
- linux如何执行定时任务
前言:最近在做一个前端监控系统,用到分表分库的功能,由于代码上无法做到实时新建表,所以只能够曲线救国,使用linux系统的定时任务来完成. ============================== ...
- Prometheus学习笔记(3)什么是node_exporter???
目录 Node_exporter安装配置启动 Node_exporter安装配置启动 node_exporter安装在被监控端,安装方式也比较简单,直接下载解压安装即可,默认启动后监听9100端口. ...
- go build -tags 的使用
go build 使用tag来实现编译不同的文件 go-tooling-workshop 中关于go build的讲解可以了解到go bulid的一些用法,这篇文章最后要求实现一个根据go bulid ...
- Linux程序在Windows下编译运行_MinGW和Cygwin
linux要在windows下编译运行,需要win下的gcc编译器,一般有两种:MinGW和Cygwin. 但某些函数在windows没有,即使使用两种工具也编译不过,需要查询windows函数并使用 ...
- 服务器安装python3环境
服务器安装python3环境 先安装相关包 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel re ...
- Windows平台 python环境配置
下载python:https://www.python.org/downloads/windows/,一般就下载 executable installer,x86 表示是 32 位机子的,x86-64 ...
- Win10 家庭版 VMware 无法启动 解决办法
引发原因 最近更新了一个补丁 KB4524147 安装后会导致 VM 无法打开(如果你没有安装hyper-v的话) 解决方案 控制面板 -> 程序 -> 查看已安装的更新 -> 找到 ...
- jmeter5.1企业级应用功能详解
apache jmeter是100%的java桌面应用程序,它被设计用来加载被测试软件功能特性.度量被测试软件的性能.jmeter可以模拟大量的服务器负载,并且jmeter提供图形化的性能分析. JM ...