JDBC-Oracle ArrayIndexOutOfBoundsException [英] JDBC - Oracle ArrayIndexOutOfBoundsException

查看:331
本文介绍了JDBC-Oracle ArrayIndexOutOfBoundsException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在oracle表中插入一行时出现异常. 我正在为Oracle 11使用ojdbc5.jar 这是我正在尝试的sql

I'm getting an Exception while trying to insert a row in oracle table. I'm using ojdbc5.jar for oracle 11 this is the sql i'm trying

INSERT INTO rule_definitions(RULE_DEFINITION_SYS,rule_definition_type,
rule_name,rule_text,rule_comment,rule_message,rule_condition,rule_active,
rule_type,current_value,last_modified_by,last_modified_dttm,
rule_category_sys,recheck_unit,recheck_period,trackable)
VALUES(RULE_DEFINITIONS_SEQ.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

,我得到以下异常.任何帮助将不胜感激.

and i get following Exception. Any help will be appreciated.


java.ljava.lang.ArrayIndexOutOfBoundsException: 15
at oracle.jdbc.driver.OracleSql.computeBasicInfo(OracleSql.java:950)
    at oracle.jdbc.driver.OracleSql.getSqlKind(OracleSql.java:623)
    at oracle.jdbc.driver.OraclePreparedStatement.(OraclePreparedStatement.java:1212)
    at oracle.jdbc.driver.T4CPreparedStatement.(T4CPreparedStatement.java:28)
    at oracle.jdbc.driver.T4CDriverExtension.allocatePreparedStatement(T4CDriverExtension.java:68)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3059)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:2961)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:5874)
    at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:232)
    at com.gehcit.platform.cds.common.util.db.DBWrapper.executeInsertOracleReturnPK(DBWrapper.java:605)

推荐答案

在Oracle Metalink(Oracle支持站点-注释ID 736273.1)中,我发现这是JDBC适配器(版本10.2.0.0.0至11.1.0.7)中的错误. .0),当您使用7个以上的位置参数调用prepareStatement时,JDBC将引发此错误.

In Oracle Metalink (Oracle's support site - Note ID 736273.1) I found that this is a bug in JDBC adapter (version 10.2.0.0.0 to 11.1.0.7.0) that when you call preparedStatement with more than 7 positional parameters then JDBC will throw this error.

如果您有权访问Oracle Metalink,则可以选择去那里下载提到的补丁.

If you have access to Oracle Metalink then one option is to go there and download mentioned patch.

另一种解决方法是解决方法-使用命名参数而不是位置参数:

The other solution is workaround - use named parameters instead of positional parameters:

INSERT INTO rule_definitions(RULE_DEFINITION_SYS,rule_definition_type,
rule_name,rule_text,rule_comment,rule_message,rule_condition,rule_active,
rule_type,current_value,last_modified_by,last_modified_dttm,
rule_category_sys,recheck_unit,recheck_period,trackable)
VALUES(RULE_DEFINITIONS_SEQ.NEXTVAL,:rule_definition_type,
:rule_name,:rule_text,:rule_comment,:rule_message,:rule_condition,:rule_active,
:rule_type,:current_value,:last_modified_by,:last_modified_dttm,
:rule_category_sys,:recheck_unit,:recheck_period,:trackable)

然后使用

preparedStatement.setStringAtName("rule_definition_type", ...)

等为该查询设置命名绑定变量.

etc. to set named bind variables for this query.

这篇关于JDBC-Oracle ArrayIndexOutOfBoundsException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆