将ResultSet rs结果集中的数据存进数组

ArrayList User_name = new ArrayList();
ArrayList ID_card = new ArrayList();
ArrayList House = new ArrayList();

while (rs.next()){
     User_name.add(new String(rs.getString("User_name").getBytes("ISO-8859-1")));
     ID_card.add(rs.getString("ID_card"));
     House.add(rs.getString("House"));
}

遍历:
for(int i = 0; i < User_name.size(); i++) {
    String user_name = (String)User_name.get(i);  //用get()方法返回的是Object类型
}

你可能感兴趣的:(java)