0

I am having similar issue while inserting data to a DB table with 27 columns. I am using NamedParameterJdbcTemplate class to insert data. Any help in this regard is really helpful. Please find the below code snippet

SqlParameterSource parameters = new MapSqlParameterSource()
.addValue("Id", 12345678)
.addValue("packageId", info.getIrocPkgId())
.addValue("isAsgn", 1)
.addValue("startTm", info.getStartTm())
.addValue("endTm", info.getEndTm())
.addValue("type", ConstantVal.TASK)
.addValue("note", ConstantVal.ETA + ":" + info.getEta())
.addValue("fdbk", ConstantVal.EMPTY)
.addValue("sCnt", 1)
.addValue("aCd", ConstantVal.ETA)
.addValue("isAuto", 1)
.addValue("dfltStartTm", info.getStartTm())
.addValue("dfltEndTm", info.getEndTm())
.addValue("aInfo", ConstantVal.EMPTY)
.addValue("stat", ConstantVal.ACTIVE)
.addValue("cnclTask", ConstantVal.ZERO)
.addValue("asgnNbr", ConstantVal.EMPTY)
.addValue("priInd", ConstantVal.ZERO)
.addValue("ovlpMatchNbr", ConstantVal.EMPTY)
.addValue("attchIds", ConstantVal.EMPTY)
.addValue("aType", ConstantVal.EMPTY)
.addValue("lInd", ConstantVal.ZERO)
.addValue("pAsgn", ConstantVal.ZERO)
.addValue("rId", ConstantVal.EMPTY)
.addValue("bInd", ConstantVal.EMPTY)
.addValue("createDtTm", new Timestamp((new Date()).getTime()))
.addValue("updatedDtTm", ConstantVal.EMPTY);
int nb = namedParameterJdbcTemplate.update(insertRecords, parameters, keyHolder,new String[] { "ID" });

SQL Query in beans.xml is given below

<bean id="insertRecords" class="java.lang.String"
scope="prototype">
<constructor-arg type="java.lang.String"
value="
INSERT
INTO
XYZ
(
    ID,
    PACKAGE_ID,
        IS_ASGN,
        START_TM,
        END_TM,
        TYPE,
        NOTE,
        FDBK,
        S_CNT,
        A_CD,
        IS_AUTO,
        DFLT_START_TM,
        DFLT_END_TM,
        A_INFO,
        STAT,
        IS_CNCL_TASK,
        ASGN_NBR,
        PRI_ASGN_IND,
        OVLP_MATCH_NBR,
        A_IDS,
        ASGN_TYPE,
        LOCK_IND,
        P_ASGN,
        R_ID,
        B_IND,
        CREATED_DT_TM,
    UPDATED_DT_TM
)
VALUES
(
    :Id,
    :packageId,:isAsgn,:startTm,:endTm,:type,:note,:fdbk,:sCnt,:aCd,:isAuto,:dfltStartTm,:dfltEndTm,:aInfo,
        :stat,:cnclTask,:asgnNbr,:priInd,:ovlpMatchNbr,:attchIds,:aType,:lInd,:pAsgn,:rId,
        :bInd,:createDtTm,:updatedDtTm) " />
</bean>

I am seeing the below error while inserting data

java.lang.ArrayIndexOutOfBoundsException
    at oracle.jdbc.driver.OracleSql.computeBasicInfo(OracleSql.java:950)
    at oracle.jdbc.driver.OracleSql.getSqlKind(OracleSql.java:623)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:1212)
    at oracle.jdbc.driver.T4CPreparedStatement.<init>(T4CPreparedStatement.java:28)
    at oracle.jdbc.driver.T4CDriverExtension.allocatePreparedStatement(T4CDriverExtension.java:68)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3140)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3042)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:6022)
    at oracle.jdbc.OracleConnectionWrapper.prepareStatement(OracleConnectionWrapper.java:679)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.pmiPrepareStatement(WSJdbcConnection.java:5071)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:4946)
    at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.createPreparedStatement(PreparedStatementCreatorFactory.java:231)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:638)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:943)
    at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:344)
  • What version of the Oracle JDBC driver are you using? This sounds like a bug inside the Oracle JDBC driver. – Mark Rotteveel Oct 30 '20 at 18:38
  • We are using the below jar version, not sure about the driver version oracle ojdbc 6 – Manoj Kumar Oct 30 '20 at 19:21
  • That is not a real version of the Oracle JDBC driver. It looks like you (or somebody else) has installed this in the maven repository of your company (or the repository on your local system) with the target Java version as the version (the 6 in ojdbc6 identifies that it is a variant of the driver for Java 6, it is not the version of the driver). It is not the actual version of the driver. – Mark Rotteveel Oct 30 '20 at 19:27
  • In any case, ojdbc6 variants of the driver are pretty outdated. You might want to update to a newer version (and maybe at the same time use a version from Maven Central [Java 8](https://search.maven.org/artifact/com.oracle.database.jdbc/ojdbc8), [Java 10](https://search.maven.org/artifact/com.oracle.database.jdbc/ojdbc10)) – Mark Rotteveel Oct 30 '20 at 19:27
  • Driver Specification-Version: Oracle JDBC Driver version - "11.1.0.6.0-Produc – Manoj Kumar Oct 30 '20 at 19:27

0 Answers0