Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database to Vector Error

Status
Not open for further replies.

JSUAlumni

Programmer
Mar 29, 2001
21
US
Can anyone tell me why the following code produces an invalid descriptor index error? I have a SQL statement that returns 1 row with two columns: time, event. Then I have 2 vectors:
Vector time = new Vector();
Vector event = new Vector();
int x = 0;
double v = 0;

while (rs1.next()){
x = rs1.getInt("Event");
v = rs1.getDouble("Time");
time.addElement(Integer.toString(x));
event.addElement(Double.toString(v));}

NumEngages.close();

If I take one of the vectors out I'm fine, but I don't think it should be that way. It seems like after it retrieves the event it moves on to the next row before I can retrieve the time. Does anyone know how to combat this.
 
If the resultset is only returning one row... take the vectors out of the while loop and then add the elements.

Did that help? I hope this helped! ;-)
- Casey Winans
 
Well, I probably said that wrong. While debugging I noticed that the query only returns one row. However, it could return more than one row, and most likely will.
 
I think I answered my own question after I posted the question. But just in case anybody else is wondering, the variables have to be assigned in the order they are returned from the query. Probably, a dumb mistake on my part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top