Oracle ExecuteBatch Exception: ArrayIndexOutOfBoundsException

Source: Internet
Author: User


Original address: http://yanwushu.sinaapp.com/oracle_executebatch_arrayindexoutofboundsexception/


When using the JDBC Interface Preparedstatement.executebatch () to execute SQL in bulk in Oracle, an exception arrayindexoutofboundsexception occurs with the following information:

Java.lang.ArrayIndexOutOfBoundsException: -32413 at    Oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers (oraclepreparedstatement.java:2672)    Atoracle.jdbc.driver.OraclePreparedStatement.executeBatch (oraclepreparedstatement.java:10688)    Atcom.keyi.xxx.dal.xx.importFile (publiccustomerimportdao.java:107)


Looks like the Oralcejdbc driver. An array out-of-bounds exception occurred in the internal Setupbindbuffers method, but what caused the exception to occur has not been clear. Found a post on the Internet, through his ideas to get a solution.


The post content is as follows:


The 10g driver apparently keeps a global serialnumber for all parameters in the entire batch, with a "short" variable. So can has at most 32768 parameters in the batch. I was havingthe same exception because I had a INSERT statement with the parameters and mybatches can be as big as the RE Cords, so 42000 > 32768 and this overflowsto a negative index. I reduced the batch factor to is safe, and all Iswell. I guess your update DML should has a larger number of parameters Perrecord, right? (My diagnostic of the bug is just deduction from the symptoms)


The Post address is:https://community.oracle.com/thread/599441?start=15&tstart=0


In general, Oracle's PreparedStatement has an upper limit on the number of parameters when executing SQL in bulk ( for different versions of the Oracle driver, this upper limit may be different for different), The number of this parameter refers to the number of addbatch * number of arguments in each SQL . For Oracle 10g drivers, this value may be 32768, sothe number of addbatch per The number of parameters in SQL should be less than this value, or error.


According to this idea, the Addbatch reduce the number of times, making each ExecuteBatch The parameter value is less than 32768 , and found the exception resolved.



Oracle ExecuteBatch Exception: ArrayIndexOutOfBoundsException

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.