Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieving column caption in access

 
mike sutton
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using getMetaData to retrieve column names from a database to build a form in one of my servlets.
I thought that

would return the caption instead of the name, but it is not, or I am doing something wrong.
How can I get the column caption in an access database instead of the column name?
Here is the code from the servlet:
 
mike sutton
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure what happened when I tried to post my code, but here it is again
 
mike sutton
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
o.k. third try, this time without the code tag:
try {
stmt = l.dbCon.createStatement();
rs = stmt.executeQuery(qry.toString());
ResultSetMetaData rsmd= rs.getMetaData();
int numberofcolumns = rsmd.getColumnCount();
while(rs.next()){
for (int i =1; i<= numberofcolumns; i++ ){

String columnlabel = rsmd.getColumnLabel(i);
String columnname = rsmd.getColumnName(i);

out.println("<tr>");
out.println("<td >" + columnlabel + "");
out.println("</td>");
out.println("<td >");
out.println("<input type='text' name='"+ columnname +"' size='25'>");
out.println("</td>");
out.println("</tr>");
}
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic