|
Select * works in JDBC. I don't see anything wrong with your app. What line of code took the exception? At that point what are the values for pRow and pColumn? David Wall Toolbox for Java iSeries ODBC Driver for Linux "Mangavalli, Ramanujam" To: "'java400-l@midrange.com'" <java400-l@midrange.com> <RamM@Mvmills.com cc: > Subject: RE: Descriptor Index not Valid. Sent by: java400-l-admin@m idrange.com 05/28/2002 11:30 AM Please respond to java400-l Dave, Here is the getValueAt method. The user keys in SELECT * FROM COLLECTIONA.TABLEA. Table A has two rows. I can see the vector values after I get all the data for the two rows. I use resultSet().getNext() to determine if there there are more rows. If the return value is false, I just set a endOfResultSet variable to True and get out. Can I not do a select * in JDBC? I set the JRE to 1.4 in eclipse. /** * getValueAt method comment. */ public Object getValueAt(int pRow, int pColumn) { Object[] dummyRow = null; int iterations = 0, oldRowCount = currentRowCount; boolean validRow; // If the row at which the value is requested is less than 0,return nothing. if (pRow < 0) return null; // If the column at which the value is requested is less than 0 // or if the column is greater than the number of columns, return nothing. if ((pColumn < 0) || (pColumn > this.getColumnCount())) return null; // If the end of the cursor is reached and the row at which the value is //requested is after the end, return nothing. if ((endOfResultSet) && (pRow > currentRowCount)) return null; // If the row is already cached, return the cached value. if ((pRow > -1) && (pRow < cachedRowCount) ) dummyRow = (Object[])cachedRow.elementAt(pRow-1); // If the row is not cached, get more rows from the result set and return // it. if ((!endOfResultSet) && pRow > cachedRowCount) iterations = pRow + READ_INCREMENT; validRow = true; for (int x = cachedRowCount + 1; (x<= iterations) && (validRow); ++x) { try { validRow = getResultSet().next(); if (validRow) { dummyRow = new Object[this.getColumnCount()]; for ( int y = 0; y <= this.getColumnCount(); ++y) dummyRow[y] = getColumnValue(y+1); // Insert element into the cache. cachedRow.insertElementAt(dummyRow, cachedRowCount++); ++lastCachedRow; if (cachedRowCount > VECTOR_MAX_SIZE) { cachedRow.removeElementAt(0); cachedRowCount--; ++firstCachedRow; } if ((!endOfResultSet) && (x > currentRowCount)) currentRowCount = x; } else if (!endOfResultSet) { endOfResultSet = true; currentRowCount = x; } } catch (Throwable thrownException) { System.out.println(thrownException.getMessage()); System.out.println("Error occurred in class name CachingResultSetTableModel in method getValueAt()"); System.out.println ("Parameters passed to method are row = " + pRow + ", column = " + pColumn); thrownException.printStackTrace(); return null; } } // If the requested row is prior to the cached contents, read rows from the result set and move the cache contents up if (pRow < firstCachedRow) { for ( int i = firstCachedRow - 1 ; i >= pRow; i--) { try { dummyRow = new Object[this.getColumnCount()]; getResultSet().absolute(i+1); for ( int y = 0; y<=getColumnCount(); ++y) dummyRow[y] = getColumnValue(y+1); cachedRow.insertElementAt(dummyRow, 0); --firstCachedRow; if (++cachedRowCount > VECTOR_MAX_SIZE) { cachedRow.removeElementAt(--cachedRowCount); --lastCachedRow; } } catch (Throwable thrownException) { System.out.println(thrownException.getMessage()); System.out.println("Error occurred in Class name CachingResultSetTableModel in method getValueAt()"); System.out.println("Parameters passed to method are row = " + pRow + ", Column = " + pColumn); endOfResultSet = true; thrownException.printStackTrace(); return null; } } } if (oldRowCount != currentRowCount) fireTableRowsInserted(oldRowCount, getRowCount()); if (dummyRow == null) return null; else return dummyRow[pColumn]; } -----Original Message----- From: Dave Wall [mailto:dawall@us.ibm.com] Sent: Tuesday, May 28, 2002 11:15 AM To: java400-l@midrange.com Subject: Re: Descriptor Index not Valid. You said "There are two rows in the table. Both of them are retrieved. When I try to get the third row, I get the Descriptor Index Not Valid error." Are you sure you don't access the result set after rs.next() returns false? The thing that worried me in your question is you said you get an error trying to get the third row of data. I would expect an error getting the third row when there are only two rows of data in the database, but I would expect a cursor-state-not-valid error. Index-not-valid usually happens when you try to read a column you didn't retrieve. For example, you do rs.getString(5) when you retrieve only four columns of data. David Wall Toolbox for Java iSeries ODBC Driver for Linux "Mangavalli, Ramanujam" To: "'java400-l@midrange.com'" <java400-l@midrange.com> <RamM@Mvmills.com cc: > Subject: Descriptor Index not Valid. Sent by: java400-l-admin@m idrange.com 05/24/2002 02:35 PM Please respond to java400-l I am getting a "java.sql.SQLException: Descriptor index not valid." Error. Anyone have any suggestions how to get rid of this? I am trying to extend the AbstractTableModel and write a custom table model and display a JTable that displays data from the iSeries 400. I am getting this error when the following is executed: validRow = getResultSet().next() if (validRow) // store row in the dummy row vector. // ... ... ... there are two rows in the table. Both of them are retrieved. When I try to get the third row, I get the Descriptor Index Not Valid error. I am using Eclipse and imported(actually I had to copy the class files into the workspace) the ET400 classes. Thanks in advance. _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.