JSP Vector Elements
843835Apr 22 2002 — edited Jul 19 2002hi,
I build up a vector of results received from a database query.
Here is the code I use:
if (resulset.next())
{
int rowcount = resultsetmetadata.getColumnCount();
do {
Vector rowVector = new Vector();
for (int i = 1; i <= rowcount ; i++) {
rowVector.addElement(resultset.getObject(i));
}
WOVector.addElement(rowVector);
} while (resultset.next());
}
The vector now returns, for instance 4 fields per element in the Vector
How, when retrieving the elements, can I easily retrieve each field in each element?
Say I get back the following two rows:
element 1 : [Peter,Blue,555]
element 2 : [Susan,White,666]
How can I retrieve the value of element2, field 2, being "White", without doing something like:
element2field2 = WOVector.elementAt(2).toString();
getting the first ",", getting the second ","
using substring to retireve the value between the two ","
etc..
?