UnableToExecuteStatementException:批量输入已中止。 调用getNextException以查看原因

使用@SqlBatch批量更新数据库

 @SqlBatch("") @BatchChunkSize(INSERT_BATCH_SIZE) void insert(@BindBean Iterator someObj); 

我收到这个错误:

org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException:java.sql.BatchUpdateException:批处理条目0 …已中止。 调用getNextException以查看原因。

问题是被捕获的exception是UnableToExecuteStatementException而不是原始的BatchUpdateException ,所以我无法调用getNextException来查看原因。 此外,我可以直接在DB中运行SQL命令。

任何想法如何找到原因的底部或问题可能是什么?

我刚看到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. 

无信息。

我抓住并打印了exception,

  } 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是一个非常奇怪的数字。 重要的是它是列数的倍数。

发生exception

 at org.postgresql.core.v3.QueryExecutorImpl.sendParse(QueryExecutorImpl.java:1329) 

是的

 pgStream.SendInteger2(params.getParameterCount()); // # of parameter types specified 

那是什么意思?

对于单个INSERT语句,值的总数(即,列数乘以行数)不得超过32767。

您可以将32767除以列数以获得每个SQL INSERT语句的最大行数。