I have created a PreparedStatement to execute a batch of
insert statements. But while executing,
the below exception occurred.
java.lang.ArrayIndexOutOfBoundsException: 22 at oracle.jdbc.driver.T4CNumberAccessor.unmarshalOneRow(T4CNumberAccessor.java:207) at oracle.jdbc.driver.T4C8Oall.readRXD(T4C8Oall.java:745) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:371) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1115) at oracle.jdbc.driver.OraclePreparedStatement.executeForRowsWithTimeout(OraclePreparedStatement.java:13106) at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:13246) at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:248) at XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Solution:
After googling, I realized that the PreparedStatement is not
accepting more than 6 parameters. Below is the statement I have used.
PreparedStatement stmtQuestions =
conDB.prepareStatement("INSERT INTO "+Properties.DB_TABLE +"
values(?,?,?,?,?,?,?)");
I changed the statement to below which avoid the above
exception and program was executed successfully.
Statement stmtQuestions=conDB.createStatement();
String query="INSERT INTO "+Properties.DB_TABLE
+"
values('"+id+"',"+sid+","+qid+",'"+sqText+"','"+sqSText+"','"+qType+"','"+qoType+"')";
stmtQuestions.addBatch(query);