How to get generated keys by executeBatch without ArrayIndexOutOfBoundsException?

回眸只為那壹抹淺笑 提交于 2019-12-01 09:22:56

This appears to be a bug in Oracle on Windows, the driver JAR ojdbc6.jar, or (knowing Oracle) both.

There's no significant problem with the code you have presented. It should work, although when I ran it the numbers of rows inserted each time was returned as -2 (= Statement.SUCCESS_NO_INFO), so you may be better off ignoring these numbers.

Your code runs fine for me with Oracle 11g XE 11.2.0.2.0 on Linux with four versions of the Oracle JDBC driver JAR. However, if I run it on Windows 10 with the same version of Oracle XE and with ojdbc6.jar, it fails with the same ArrayIndexOutOfBoundsException you are getting. The problem goes away if I use ojdbc7.jar instead of ojdbc6.jar.

Therefore, I would recommend replacing ojdbc6.jar with ojdbc7.jar, which you can download from here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!