• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

retrieving column caption in access

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>");
}
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic