java.lang.arrayindexOutOfBoundsEXCEPTION:22

时间:2015-11-07 11:17:10

标签: java oracle jdbc

此问题发布在此OTN社区主题中:Can getGeneratedKeys() be used when executing batches of statements?

但遗憾的是我没有找到合适的答案。

该线程现已锁定,所以我想在这里重新开始。

这是另一个主题的摘要:

  

您可以检索一批insert语句生成的密钥吗?该   以下代码从中生成 ArrayIndexOutOfBoundsException   Oracle T4CNumberAccessor.unmarshalOneRow()方法(请参阅堆栈跟踪)   这条消息的底部)。

     

代码是:

String sql = "INSERT INTO FOO (ID, NAME) VALUES (FOO_SEQ.NEXTVAL, ?)";
 String generatedColumns[] = {"ID"};
 PreparedStatement pstmt = connection.prepareStatement(sql, generatedColumns);

pstmt.setString(1, "A");
 pstmt.addBatch();
 pstmt.setString(1, "B");
 pstmt.addBatch();
 pstmt.setString(1, "C");
 pstmt.addBatch();

//EXCEPTION OCCURS HERE
 pstmt.executeBatch();
     

例外是:

java.lang.ArrayIndexOutOfBoundsException: 22
at oracle.jdbc.driver.T4CNumberAccessor.unmarshalOneRow(T4CNumberAccessor.java:190)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:610)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10580)

0 个答案:

没有答案