【发布时间】:2017-02-14 09:07:18
【问题描述】:
我正在执行语句查询并将数据存储在 ResultSet rs 中。
// if no record is returned by the query
if (!rs.next() ) {
Step1
}
// if atleast one record is returned by the query
if(rs.next()){
do {
if (rs.getString(1).equalsIgnoreCase("0")){
Step2
}
if (rs.getString(1).equalsIgnoreCase("1")){
Step3
}
} while (rs.next());
}
但是,如果我从查询中只获得一条记录,则不会执行任何步骤。如果有人能指出错误,那将是非常有帮助的。
【问题讨论】:
-
注意:
if(condition) do{ } while(condition);,如果条件完全相同,则与while(condition){}相同,除非您使用else,在其中可以添加Step1