Dear Experts
When we create table in MS Access we enter description of field in description column. I am able to get the field name and data type from the table but how can I get the description from the table.
Here is the code by which I am getting field name

public ArrayList<String> fetchtable(String value)
{
   try
   {
       makeConnection();
       String str1="Select * from "+ value;
       ResultSet rs = st.executeQuery(str1);
       rsmd = rs.getMetaData();
       NumOfCol= rsmd.getColumnCount();
       for(int i=1;i<=NumOfCol;i++)
       {
          ColumnName = rsmd.getColumnName(i);
          System.out.println(ColumnName);
          columns.add(ColumnName);
       }
      //System.out.println("Columns Valuessss is:" +columns);
    }catch(Exception ae){
      ae.printStackTrace();
     }
    return columns;
}

Kindly refer the image
4bfe0a317b79c671bff1964504f53eac

what is columns? where is this called?
do you get an error? do you get a stacktrace? do you get an unexpected result?
did you debug? or at least, add some print statements to see what ColumnName values are added? what is the input? what is the actual result?

can you show more of your code? if your calling method uses the same variables, are you sure they're nowhere being overwritten?

I suggest you start looking at naming conventions, it 'll make your code a lot easier to read/understand.

Have you tried getColumnLabel instead of getColumn Name ?

@JamesCherrill I already got the name of fields like ID and Name also I am able to get the data type like autonumber and Text but how to get the description like -Student Admission Number and Student Name, here I am stuck. I don't know what to use or how to get these descriptions

Vishalonne : why exactly do you need that? it's a bit like you put commentary in your class, and you expect another class to be able to read that using a getter ..

@JamesCherrill I already got the name of fields like ID and Name also I am able to get the data type like autonumber and Text but how to get the description like -Student Admission Number and Student Name, here I am stuck. I don't know what to use or how to get these description

Yes, but did you try getColumnLabel instead of getColumnName ?

@stultuske I need this to know about the field for example if there is a field named as sgc type of this field is boolean and description of this field is Single Girl Child. My user will get the proper information regarding the field.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.