rs.next()的理解

解释此段代码的意思
try {
pstmt = conn.prepareStatement(sql);//预编译
rs = pstmt.executeQuery();//执行查询语句
while(rs.next()) //rs 游标下移,rs.next()返回一个布尔值,为true,则数据表中有记录,否则没有记录。next()可以遍历全部数据。
{
Caipin caipin = new Caipin();//创建对象
caipin.setId(rs.getInt(“id”));//rs自带的get方法,获取到数据库中的各个属性
caipin.setName(rs.getString(“name”));
caipin.setMiaoshu(rs.getString(“miaoshu”));
caipin.setPrice(rs.getFloat(“price”));
caipin.setVipprice(rs.getFloat(“vipprice”));
msg.add(caipin);
}

你可能感兴趣的:(rs.next()的理解)