E
enteraj
Unregistered / Unconfirmed
GUEST, unregistred user!
在Java查询中,怎样判断所查询的记录集为空。我是这样实现的,怎么不行乞死我!!!
temp="Select * from test where name="+"'"+sql_txt.getText()+"'";
ResultSet rst=smt.executeQuery(temp);
if (rst.wasNull()==false){ //注意就是这里
while(rst.next()){
istemp=rst.getString("name")+" "+rst.getString("sex");
chat_txt.append(istemp);
chat_txt.append(" ");
}
}
else
{
chat_txt.append("为空!");
}
temp="Select * from test where name="+"'"+sql_txt.getText()+"'";
ResultSet rst=smt.executeQuery(temp);
if (rst.wasNull()==false){ //注意就是这里
while(rst.next()){
istemp=rst.getString("name")+" "+rst.getString("sex");
chat_txt.append(istemp);
chat_txt.append(" ");
}
}
else
{
chat_txt.append("为空!");
}