另一个字符串我有以下布局的数据库在MySQL比较数据库字段的值在Java
databasename:macfast
table name:users
columns
id,
user_name,
password,
fullName
我想要从列USER_NAME所有的值,并检查各值与另外一个字符串,它是已经从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);
}
}
NullPointerException发生在哪一行? – mthmulders
什么都没发生.... –
没有值为参数1指定....所以空点豁免 –