一、报错信息
Mybatis + PostgreSQL-JDBC-Driver 42.1.4批量插入24178条数据(每条30字段).报如下错误:
PgSQL 9.6
Cause: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
; SQL []; An I/O error occurred while sending to the backend.; nested exception is org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
Tried to send an out-of-range integer as a 2-byte value: 647430
二、报错原因
- 这里是JDBC-Driver 一条SQL参数数量达到了上限,幂增操作的参数=记录数(行)插入的字段数(列)。
- JDBC-Driver 支持的参数数量跟版本(x.y.z)和类型(xx数据库)有关。
三、解决思路
分割成小段
- JDK 8 版本
- 示例代码
/**
* <code>Details determine success.</code>
* by Liang ZC., Phd@Stanford
*
* @author LIANGZHICHENG
* @date 2019-8-9 18:03
* @see http://www.stanford.edu
*/
public class TestUtils {
@Autowired