Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法执行ExecuteStatementException:批处理条目已中止。调用getNextException查看原因_Java_Sql - Fatal编程技术网

Java 无法执行ExecuteStatementException:批处理条目已中止。调用getNextException查看原因

Java 无法执行ExecuteStatementException:批处理条目已中止。调用getNextException查看原因,java,sql,Java,Sql,使用@SqlBatch批量更新数据库 @SqlBatch("<SQL Command>") @BatchChunkSize(INSERT_BATCH_SIZE) void insert(@BindBean Iterator<SomeObj> someObj); @SqlBatch(“”) @BatchChunkSize(插入批次大小) void insert(@BindBean迭代器someObj); 我得到一个错误: org.skife.jdbi.v2.except

使用
@SqlBatch
批量更新数据库

@SqlBatch("<SQL Command>")
@BatchChunkSize(INSERT_BATCH_SIZE)
void insert(@BindBean Iterator<SomeObj> someObj);
@SqlBatch(“”)
@BatchChunkSize(插入批次大小)
void insert(@BindBean迭代器someObj);
我得到一个错误:

org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: java.sql.BatchUpdateException:批处理条目0。。。被中止。呼叫 getNextException以查看原因

问题是捕获到的异常是一个
无法执行的异常
,而不是原始的
批更新异常
,因此我无法调用
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.
缺乏信息

我捕获并打印了异常

    } 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语句的最大行数。

我发现使用DataPipeline CopyActivity将Aurora(MySQL)导入到Redshift时出现类似问题。 我可以通过将传入数据强制转换为insertQuery中适当的目标表类型来解决此问题,如下所示:

INSERT INTO my_table (id, bigint_col, timestamp_col) VALUES (?,cast(? as bigint),cast(? as timestamp))