〓〓〓JSP的读取数据类-----如何将记录集转为二维数组返回
我以前用PHP的时候 
 可以很轻易将记录集转为二维数组返回,PHP的优点是声明数组不用指定类型     
 我在JSP的数据库类有一个读取记录集的function,我不想返回Resultset给JSP页面,我只想返回纯数组给JSP页面   
 function   String[][]      get_rs() 
 { 
          String[][]   rs;    
       ......读取记录集省略.... 
          return   rs; 
 }   
 我要把记录集放入数组有几个问题 
 1、记录集的条数和字段数可能是不固定的,java如果定义一个下标自动的二维数组? 
 2、如果我的记录集字段可能有多种数据类型,但数组只能定义一种类型,怎么解决?   
------解决方案--------------------定义bean啊,这个bean和数据库的表的一条记录对应啊 
 比如说 
 public class User 
 { 
     private String name; 
     private String password; 
     public String getName() 
    { 
      return name; 
     } 
 public String setName(String name) 
    { 
      this.name=name; 
     } 
 public String getPassword() 
    { 
      return password; 
     } 
 public String setPassword(String password) 
    { 
      this.password=password; 
     } 
 }     
 因为个不定,所以建议用集合类 
 function Collection  get_rs() 
 { 
    Collection coll = new ArrayList(); 
    while(rs.next()) 
  { 
       User user = new User(); 
       user.setName(rs.getString( "name ")); 
       user.setPassword(rs.getString( "password ")); 
       coll.add(user); 
  }     
   return coll; 
 }     
 在页面上 
 Collection coll = 返回来的coll; 
 Iterator it = coll.iterator(); 
 while(in.hashNext()) 
  {  
       User user = (User)it.next(); 
       out.println(user.getName()); 
       out.println(user.getPassword()); 
   }