次のレイアウトのデータベースがあります
databasename:macfast
table name:users
columns
id,
user_name,
password,
fullName
列 user_name からすべての値を取得し、各値を .But から既に取得されている別の文字列でチェックしたいのですが、TEXTFIELD
できません( NullpointerException
)。私を助けてください。
public void deleteFclty() {
PreparedStatement stmt = null;
ResultSet rs = null;
String username=removeText.getText();
String qry = "SELECT user_name From users ";
try {
stmt = (PreparedStatement) connection.prepareStatement(qry);
rs = stmt.executeQuery();
while (rs.next()) {
String check=(rs.getString("user_name"));
System.out.println(check);
if(check.equals(username)){
Util.showErrorMessageDialog("EQUAL");
}else{
Util.showErrorMessageDialog("NOT EQUAL");
}
}
}catch (SQLException ex) {
Logger.getLogger(RemoveFaculty.class.getName()).log(Level.SEVERE, null, ex);
}
}