我正在执行Statement查询并将数据存储在ResultSet rs中。关于ResultSet的查询
// 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'' – AxelH