例外:java.lang.ArrayIndexOutOfBoundsException OraclePreparedStatement

时间:2017-10-12 20:21:36

标签: java prepared-statement oracle12c

我收到一个异常java.lang.ArrayIndexOutOfBoundsException,调用方法executeBatch:

java.lang.ArrayIndexOutOfBoundsException
    at java.lang.System.arraycopy(Native Method)
    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:11107)
    at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:244)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)

这是代码:

// list with 2500 entries   
for (CMInfo cm : list) {
    if (cm != null) {
        int i = 1;
        stmt.setTimestamp(i++, cm.getDate());
        stmt.setString(i++, cm.getId());
        stmt.setString(i++, cm.getName());
        stmt.setString(i++, cm.getCMap()); // +/- 3000 characteres
        stmt.setString(i++, cm.getCMapIds()); // +/- 2000 characteres
        stmt.setTimestamp(i++, cm.getLastUpdate());
        stmt.setString(i++, cm.getInstance());
        stmt.setString(i++, cm.getStatus());
        stmt.setString(i++, cm.getProcessingID());
        stmt.setInt(i++, cm.getCounter());
        stmt.setInt(i++, cm.getPriority());
        stmt.addBatch();
    }
}

stmt.executeBatch();
connection.commit();

1 个答案:

答案 0 :(得分:0)

在使用ojdbc7.jar驱动程序包的同时从Oracle 11g切换到Oracle 12c后,我遇到了类似的异常。 更新驱动程序解决了我的问题。 我建议您尝试使用ojdbc8.jar驱动程序包:

http://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html

它确实需要Java 8。