dcsimg

How does one get column names for rows returned in a ResultSet?

Jason Stell

ResultSet rs = ...
...
ResultSetMetaData rsmd = rs.getMetaData();
int numCols = rsmd.getColumnCount();

for (int i = 1; i <= numCols; i++) 
{
  System.out.println("[" + i + "]" + 
     rsmd.getColumnName(i) + " {" + 
     rsmd.getColumnTypeName(i) + "}");
}