我刚刚在 Hibernate 和 Postgres 中看到了类似的情况。据我了解,问题出在 PostgreSQL 驱动程序 (org.postgresql.core.v3.QueryExecutorImpl) 中。
我看到的是:
java.sql.BatchUpdateException: Batch entry 0 INSERT INTO myscheme.table_name (list,of,column,names,...) VALUES (9007199314139196, 'F', 27, 625, 625, 625, 625, 625, 28), (9007199314139198, 'T', 2395, 2369, 2369, 2369, 2369, 2369, 2389), ... was aborted. Call getNextException to see the cause.
信息量不大。
我捕获并打印了异常,
} catch(JDBCConnectionException t) {
System.out.println("================ {{{");
SQLException current = t.getSQLException();
do {
current.printStackTrace();
} while ((current = current.getNextException()) != null);
System.out.println("================ }}}");
throw t;
}
得到:
Caused by: java.io.IOException: Tried to send an out-of-range integer as a 2-byte value: 33300
仍然令人困惑。 33300是一个很奇怪的数字。重要的是它是列数的倍数。
异常发生
at org.postgresql.core.v3.QueryExecutorImpl.sendParse(QueryExecutorImpl.java:1329)
这是
pgStream.SendInteger2(params.getParameterCount()); // # of parameter types specified
这是什么意思?
单个INSERT语句的值总数,即列数乘以行数不能超过32767。
您可以将 32767 除以列数,以获得每个 SQL INSERT 语句的最大行数。