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 ...
随机推荐
- 前端1-----块级标签(独占一行),排版标签(样式排版),其他标签,form表单(input的多种类型)
前端1-----块级标签(独占一行),排版标签(样式排版),其他标签,form表单(input的多种类型) 一丶HTML块级标签 排版标签 p 标签: 段落标签,会自动在段落上下加上空白来分开 p标签 ...
- Java小知识点总结01
1. 整数相乘或者相加,如果超过最大整数值,会变成负数 2. 字符串比较可以使用:s1.compareTo(s2) ,如果s1大于s2返回值大于1,等于返回值等于0,小于返回值小于1 3. char值 ...
- OpenGL 中的三维纹理操作
#define _CRT_SECURE_NO_WARNINGS #include <gl/glut.h> #include <stdio.h> #include <std ...
- 7.JavaScript-Promise的并行和串行
Promise 并行 Promise.all是所有的Promise执行完毕后(reject|resolve)返回一个Promise对象. 最近在开发一个项目中,需要等接口拿到全部数据后刷新页面,取消l ...
- vs2017 添加 mysql EF实体数据模型闪退
1.查看vs2017安装路径找到Mysql.Data.dll版本号与MySQL Connector Net版本是否一致 历史版本下载地址 http://mysql.inspire.net.nz/Dow ...
- vue + yarn 项目开发 (一)
1.打开src文件夹中的main.js文件,添加引用element ui框架 import ElementUI from 'element-ui' import 'element-ui/lib/the ...
- map字典,储存cookie,切换账户,展示购物车不同商品
1:首页 1,静态html5+css做好基本样式 html5,css,jQery, sass 2,jsonp的方式src引入模拟的json数据//这里用的jsonp方式拿数据,详情有使用ajax 遍历 ...
- Android源码分析(七)-----如何解决java编译版本问题
一 : 问题描述 Your version is: java version "1.6.0_31" Java(TM) SE Runtime Environment (build 1 ...
- Log4j配置详述
/** * log4j基础配置步骤阐述: * 1.引入log4j相关的jar包文件. * 2.创建log4j的配置文件. * 3.测试配置是否成功. */ Log4j 根配置语法 下面引入一 ...
- 《linux就该这么学》课堂笔记04 常用命令cat、mor...tar、find
本节命令汇总 命令 说明 格式 常用参数 实例 备注 cat 查看纯文本文件(内容较少) cat [选项] 文件名称 -n 显示行号 cat -n install-setup-ks.cfg 查看ins ...