How do I load the contents of a JDBC ResultSet into a Vector of Vectors?
This approach returns an error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0Code:theStmt = con.createStatement(); ResultSet tQ = theStmt.executeQuery( theQuery ); Vector theDataVector = new Vector(); Vector theRowVector; while ( tQ.next() ) { theRowVector = new Vector(); theRowVector.setElementAt( ricq.getString( "field1" ), 0 ); // field1 theRowVector.setElementAt( ricq.getString( "field2" ), 1 ); // field2 theRowVector.setElementAt( ricq.getString( "field3" ), 2 ); // field3 ... theRowVector.setElementAt( ricq.getString( "fieldX" ), 10 ); // fieldX theDataVector.addElement( theRowVector ); }
at java.util.Vector.setElementAt(Vector.java:482)
at ReaderJobUPDATE_PS_2.main(ReaderJobUPDATE_PS_2.java:531)
This code returns another error message:
//SQLException: Column Index out of range ( 0 > 11).Code:theStmt = con.createStatement(); ResultSet tQ = riConfirmStmt.executeQuery( theQuery ); while ( tQ.next() ) { for( int i = 0; i < 20; i++ ) { for( int j = 0; j < 11; j++ ) { ((Vector)theDataVector.elementAt(i)).setElementAt( tQ.getString(i), j ); // pop_id } } }
//Transaction is being rolled back
//SQLException: Can't call commit when autocommit=true
What do "0 >= 0" and especially "0 > 11" (!!) refer to, and how do I fix them?
Many thanks in advance.




Reply With Quote