JDBC - Oracle ArrayIndexOutOfBoundsException

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

问题描述

我在尝试在 oracle 表中插入一行时遇到异常.我将 ojdbc5.jar 用于 oracle 11这是我正在尝试的 sql

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)值(规则定义_SEQ.NEXTVAL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

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

<前>java.ljava.lang.ArrayIndexOutOfBoundsException: 15在 oracle.jdbc.driver.OracleSql.computeBasicInfo(OracleSql.java:950)在 oracle.jdbc.driver.OracleSql.getSqlKind(OracleSql.java:623)在 oracle.jdbc.driver.OraclePreparedStatement.(OraclePreparedStatement.java:1212)在 oracle.jdbc.driver.T4CPreparedStatement.(T4CPreparedStatement.java:28)在 oracle.jdbc.driver.T4CDriverExtension.allocatePreparedStatement(T4CDriverExtension.java:68)在 oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3059)在 oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:2961)在 oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:5874)在 org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:232)在 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 个位置参数调用 PreparedStatement 时,JDBC 将抛出此错误.

如果您可以访问 Oracle Metalink,那么一种选择是去那里下载提到的补丁.

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

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)值(规则定义_SEQ.NEXTVAL,:规则定义类型,: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", ...)

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

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)

解决方案

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.

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)

and then use

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

etc. to set named bind variables for this query.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)