• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Exception while inserting a row with resultSet.insertRow()

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to insert a row in Access db using resultSet.moveToInsertRow() and then resultSet.insertRow. But it gives me the following error which occurs when it tries to execute resultSet.insertRow statement.
java.lang.ArrayIndexOutOfBoundsException
at sun.jdbc.odbc.JdbcOdbcResultSet.bindCol(JdbcOdbcResultSet.java:4485)
at sun.jdbc.odbc.JdbcOdbcResultSet.insertRow(JdbcOdbcResultSet.java:3941)
I am using updateXXX to update the columns.
I can connect to database and navigate through the resultset, but problem occurs only while inserting a row.
Can anyone please guide me to work around this problem.
Thanks
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Raj,
Would you send me the code where you are trying this. I will try my best to help.
Smita
 
Raj Verma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Smita, here is the code. The data[][] stores one row and according to the type of the column, it executes updates.
ResultSetMetaData metaData; //Initialized in other proc
ResultSet resultSet; //Initialized in other proc

String[][] data; //holds a single row at a time along with col
// names. eg data[0][0] = colname &
// data[0][1] = value of colname
resultSet.moveToInsertRow();
for(int i = 0; i < data.length; i++)
{
colPos = resultSet.findColumn(data[i][0]);
switch (metaData.getColumnType(colPos))
{
case Types.INTEGER :
if (metaData.isAutoIncrement(colPos) == false)
{
resultSet.updateInt(data[i][0], Integer.parseInt(data[i][1]));
}
break;
case Types.VARCHAR :
resultSet.updateString(data[i][0], data[i][1]);
System.out.println("hey default");
break;
}
}
resultSet.insertRow(); // This is the place where the error
// occurs
Hope this code is clear. Please let me know if you have any questions.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic