StoredProcedureItemReader抛出java.lang.ArrayIndexOutOfBoundsException

时间:2014-09-25 12:30:08

标签: java spring-batch indexoutofboundsexception

当我的程序没有返回任何行时,无法从作业执行中获得控制权。当记录存在时,这可以正常工作。

StoredProcedureItemReader用法的代码片段:

<bean id="storedProcItemReader" 
class="org.springframework.batch.item.database.StoredProcedureItemReader"
    scope="step">
    <property name="dataSource" ref="dataSource" />
    <property name="rowMapper" ref="custRowMapper" />
    <property name="procedureName" value="getAllCustomers" />
    <property name="parameters">
        <list>
            <bean class="org.springframework.jdbc.core.SqlParameter">
                <constructor-arg index="0" value="custId"/>
                <constructor-arg index="1">
                    <util:constant static-field="java.sql.Types.VARCHAR"/>
                </constructor-arg>
            </bean>
        </list>
    </property>
    <property name="preparedStatementSetter" ref="custPreparedStatementSetter" />   
</bean>

抛出异常:

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.mysql.jdbc.CallableStatement$CallableStatementParamInfo.getParameter(CallableStatement.java:291)
at com.mysql.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:684)
at com.mysql.jdbc.CallableStatement.getObject(CallableStatement.java:1576)
at org.springframework.batch.item.database.StoredProcedureItemReader.openCursor(StoredProcedureItemReader.java:216)
at org.springframework.batch.item.database.AbstractCursorItemReader.doOpen(AbstractCursorItemReader.java:403)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139)

版本:mysql 5.6,spring batch 3.0.1.RELEASE,mysql-connector-java 5.1.32

0 个答案:

没有答案