Connection conn=getConnection();
    Vector list=new Vector();
    try
    {
       stmt=conn.createStatement();
       ResultSet rs=stmt.executeQuery("select sortID,sortName,child_sort_id,child_sort_name");
       while(rs.next() )
       {
          Hashtable ht=new Hashtable();
          int field =rs.getInt(1);
          String value=rs.getString(2);
          ht.put(field,value);
          list.add(ht);
       }
              
    }catch(SQLException e)
    {}在数据库里查询的结果为:
sortID sortName child_sort_id  child_sort_name
但经过以上程序后,取得的值为:
sortID child_sort_name child_sort_id   sortName
sortName 和 child_sort_name  的位置交换了,这是怎么回来呢??如果只有两列的话就正常了

解决方案 »

  1.   

    把Hashtable ht=new Hashtable();
    改成 Map ht = new LinkedHashMap();就可以了另外,建议你以后不要使用HashTable了
      

  2.   

    不解,为什么不要用Hashtable 只是想知道为什么而己
      

  3.   

    hashtable  已经不建议使用了,另外,他是并发的,效率低下。
      

  4.   

    为啥会出现列的顺序改变,应该和HASHTABLE没关系吧?
      

  5.   

    问题己解决,只是用Map map=new LinkedHashMap() 稍微麻烦些