I have a vector in which i'm storing a resultSet. Each Element of the resultSet is one row from a db. I need to get the items out of the vector one at a time and place them in a form somewhere. My problem is I can't seem to figure out how to get the items out of the vector one at a time and place them where they need to go. This is what I have so far. try { ResultSetMetaData rmeta = rsGl.getMetaData(); columns = rmeta.getColumnCount(); colnames = new Vector(); for (int i = 1; i <= columns; ++i) { colnames.addElement(rmeta.getColumnLabel(i)); } rows = new Vector(); rows.addElement(colnames); rowcount = 0; while (rsGl.next()) { rowcount = rowcount + 1; Vector newRow = new Vector(); for (int j = 1; j <= columns; j++) { value = rsGl.getObject(j); newRow.addElement(value); } rows.addElement(newRow); } System.out.println("Capacity " + rows.capacity()); for(int i = 0; i < 25; ++i) { System.out.println("Vector Item at " + i + ": " + rows.elementAt(i)); } Iterator vItr = rows.iterator(); while(vItr.hasNext()) System.out.println(vItr.next() + " "); } Can anyone point me in the right direction please..... Thanks
A better implementation is to store a ResultSet row in a Hashtable, then store the row in the Vector, and use Enumerations to get the stuff back out. For example:
This won't likely compile, but you should catch my drift. Let us know what you end up with.
CJP (Certifiable Java Programmer), AMSE (Anti-Microsoft Software Engineer)
Author of Posts in the Saloon