struts2框架的数据层就是查不出东西是为什么

public ArrayList selectAllComment(){
Connection conn = DBUtil.getConnection();
try {
PreparedStatement ps =
conn.prepareStatement("select * from hkcomment c,hkusers u where c.userid=u.userid");
ResultSet rs = ps.executeQuery();
ArrayList allcomment= new ArrayList();
while(rs.next()) {
Comment ru=new Comment();
ru.setCid(rs.getString("cid"));
ru.setCtitle(rs.getString("ctitle"));
ru.setCcontent(rs.getString("ccontent"));
ru.setCtime(rs.getString("ctime"));
Users u=new Users();
u.setUserid(rs.getString("userid"));
u.setUname(rs.getString("uname"));
u.setPassword(rs.getString("password"));
u.setRole(rs.getString("role"));
u.setWrongnum(rs.getInt("wrongnum"));
u.setUstatus(rs.getString("ustatus"));
ru.setUsers(u);
}
// 当循环结束时,所有用户信息都封装到ArrayList集合中
DBUtil.closeAll(conn, ps, rs);
return allcomment;

    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
查看全部
zhmt024
zhmt024
2015/06/14 23:53
  • 集合
  • 点赞
  • 收藏
  • 回答
    私信

2个回复