jsp页面中为什么只显示一条记录啊
while(rs.next()){HelyBeanvb=newHelyBean();vb.setUserName(rs.getString("username"));vb...
while(rs.next()){
HelyBean vb = new HelyBean();
vb.setUserName(rs.getString("username"));
vb.setSum(rs.getString("sum"));
sql = "select t.sub from user_con t where t.username='"+vb.UserName()+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
vb.setSub(rs.getString("sub"));
}
sql = "select t.mob from user_mob t where t.sum='"+vb.getSum()+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
vb.setNumber(rs.getInt("mob"));
}
list.add(vb);
}
这是后台的一部分代码,麻烦帮忙看下什么问题吧 展开
HelyBean vb = new HelyBean();
vb.setUserName(rs.getString("username"));
vb.setSum(rs.getString("sum"));
sql = "select t.sub from user_con t where t.username='"+vb.UserName()+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
vb.setSub(rs.getString("sub"));
}
sql = "select t.mob from user_mob t where t.sum='"+vb.getSum()+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
vb.setNumber(rs.getInt("mob"));
}
list.add(vb);
}
这是后台的一部分代码,麻烦帮忙看下什么问题吧 展开
3个回答
展开全部
rs在循环里面被你改了,最外层的while循环就出问题了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
HelyBean vb = new HelyBean();
vb.setUserName(rs.getString("username"));
vb.setSum(rs.getString("sum"));
sql = "select t.sub from user_con t where t.username='"+vb.UserName()+"'";
rs = stat.executeQuery(sql);
while(rs.next()){
vb.setSub(rs.getString("sub"));
}
sql = "select t.mob from user_mob t where t.sum='"+vb.getSum()+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
vb.setNumber(rs.getInt("mob"));
}
list.add(vb);
}
vb.setUserName(rs.getString("username"));
vb.setSum(rs.getString("sum"));
sql = "select t.sub from user_con t where t.username='"+vb.UserName()+"'";
rs = stat.executeQuery(sql);
while(rs.next()){
vb.setSub(rs.getString("sub"));
}
sql = "select t.mob from user_mob t where t.sum='"+vb.getSum()+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
vb.setNumber(rs.getInt("mob"));
}
list.add(vb);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询