why do U execute this operation: 'A as B'?
"select A as B from table" can get A

解决方案 »

  1.   

    thanks for your help.
    here's my code;Query q = new String("select namea as nameb from table;");
    ResultSet resultSet = statement.excuteQuery(q);
    ResultSetMetaData rsmd = resultSet.getMeta();
    System.out.println( rsmd.getColumnName(1) );
    the output is:nameb
    what i want to obtain is the original column name "namea".
      

  2.   

    'namea as nameb' is just give a alias to namea, the nameb have the content which namea had, If you use "select namea from table;" ,you can also have the same resultset, I just not quit sure why U use 'namea as nameb' here, and then why you want to get the ColumnName as namea,if the nameb don't have special meaning here ,I suggest you use "select namea from table;"
      

  3.   

    thanks a lot,ddbean :) One of my class needs to know both the alias and the original column name, though the "select namea from table;" and the "select namea as nameb from table;" will generate the some resultset.i searched many forums and found no solution.
    it seems that it's impossible to obtain the original column name.:(
    i'm considering making some changes in my design.
      

  4.   

    I have another suggestion:
      U can use "select namea as nameb from table;" to get a resultset, but when you want to get your original column name, try to get it in the table of database, do not get it in the resultset.
     
    Good Luck!!!