Java Prepared Statement Error
- by Suresh S
Hi Guys the following code throws me an error i have an insert statement created once and in the while loop i am dynamically setting parameter , and at the end i says ps2.addBatch() again
while ( (eachLine = in.readLine()) != null))
{
for (int k=stat; k <=45;k++)
{
ps2.setString (k,main[(k-2)]);
}
stat=45;
for (int l=1;l<= 2; l++)
{
ps2.setString((stat+l),pdp[(l-1)]);// Exception
}
ps2.addBatch();
}
This is the error
java.lang.ArrayIndexOutOfBoundsException: 45
at
oracle.jdbc.dbaccess.DBDataSetImpl._getDBItem(DBDataSetImpl.java:378)
at
oracle.jdbc.dbaccess.DBDataSetImpl._createOrGetDBItem(DBDataSetImpl.java:781)
at
oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2450)
at
oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1155)
at
oracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:1572)
at
Processor.main(Processor.java:233)