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) + "}");
}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact