Java Prepared Statement Error

Posted by Suresh S on Stack Overflow See other posts from Stack Overflow or by Suresh S
Published on 2010-12-22T07:13:17Z Indexed on 2010/12/22 7:54 UTC
Read the original article Hit count: 253

Filed under:
|
|

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)

© Stack Overflow or respective owner

Related posts about java

Related posts about sql