This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Exception while inserting a row with resultSet.insertRow()
Raj Verma
Greenhorn
Joined: Apr 17, 2001
Posts: 5
posted
0
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
/.\ /.\<BR> ----<BR> `..'
Smita Tyagi
Greenhorn
Joined: May 09, 2001
Posts: 21
posted
0
Hello Raj, Would you send me the code where you are trying this. I will try my best to help. Smita
Raj Verma
Greenhorn
Joined: Apr 17, 2001
Posts: 5
posted
0
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.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Exception while inserting a row with resultSet.insertRow()