我有一个具有以下布局的数据库
databasename:macfast
table name:users
columns
id,
user_name,
password,
fullName
我想从 user_name 列中检索所有值,并用另一个字符串检查每个值,该字符串已经从 a 中检索到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);
}
}