テーブル「admin」を持つデータベースがあります。しかし、現在、値を持たないテーブルを作成しています。テーブルの列はuser_nameとpasswordです。私の動機は、テーブルが空かどうかを確認することです。私はmysqlデータベースを使用しています。コードとその失敗。助けてください。
public void nullCheck() {
PreparedStatement stmt = null;
ResultSet rs = null;
String qry = "SELECT * From admin ";
try {
stmt = (PreparedStatement) conn.prepareStatement(qry);
rs = stmt.executeQuery();
boolean empty = true;
while( rs.next() ) {
// ResultSet processing here
empty = false;
}
if( empty ) {
Util.showWarningMessageDialog("null");
}
} catch (SQLException ex) {
Logger.getLogger(RemoveFaculty.class.getName()).log(Level.SEVERE, null, ex);
}
}