idea查询数据库时结果只重复显示最后一条数据(已解决)
作者:互联网
部门源码(问题所在):
List<AqProjectType> list = new ArrayList<AqProjectType>();
AqProjectType aq = new AqProjectType();
while(rs.next()) {
aq.setId(rs.getString(1));
aq.setName(rs.getString(2));
aq.setCode(rs.getString(3));
aq.setREMARK(rs.getString(4));
aq.setSTATUS(rs.getString(5));
aq.setMakedep(rs.getString(6));
aq.setMakeuser(rs.getString(7));
aq.setInsert_date(rs.getString(8));
list.add(aq);
}
以上问题所在:
AqProjectType aq = new AqProjectType();
修改new对象的位置即可:
List<AqProjectType> list = new ArrayList<AqProjectType>();
AqProjectType aq = null;
while(xx.next()){
aq = new AqProjectType();
aq.setId(rs.getString(1));
aq.setName(rs.getString(2));
aq.setCode(rs.getString(3));
aq.setREMARK(rs.getString(4));
aq.setSTATUS(rs.getString(5));
aq.setMakedep(rs.getString(6));
aq.setMakeuser(rs.getString(7));
aq.setInsert_date(rs.getString(8));
list.add(aq);
}
有被自己蠢到
标签:getString,rs,重复,list,idea,aq,查询数据库,AqProjectType,new 来源: https://www.cnblogs.com/fanguoan/p/15715491.html