> I have a resultset that is returned from a query, and i don't know the
> amount of columns it has in it. Does anyone know of a way i can get
> all the data out of a record without knowing the exact amount of
> columns?? Thanks.
You can't, but you can get its ResultSetMetaData and find out the number
of columns in the ResultSet from there.

Signature
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
> I have a resultset that is returned from a query, and i don't know the
> amount of columns it has in it. Does anyone know of a way i can get
> all the data out of a record without knowing the exact amount of
> columns?? Thanks.
ResultSet rs = statement.executeQuery("select col1,col2,col3 from
mytable");
java.sql.ResultSetMetaData rsmd = rs.getMetaData();
int colNo = rsmd.getColumnCount();
while(rs.next()){
Object[] objects = new Object[colNo];
for(int i=0;i<colNo;i++){
objects[i]=rs.getObject(i+1);
}
}

Signature
Real Gagnon from Quebec, Canada
* Looking for Java or PB snippets ? Visit Real's How-to
* http://www.rgagnon.com/howto.html
james - 23 Jun 2004 17:05 GMT
thanks everyone for the help. I dug around on my own and found the
metadata piece and got it working. Find it weird that they make you
get info from an onject through another object, but i assume that is
how they do... Interesting enough. Thanks for the quick and helpful
results.
j