我创建了一个登录类,但我仍然有一个零点异常错误消息,我无法了解他的来源请帮助我,这是我的代码和消息错误
public boolean Authentification(String user, String password){
boolean result=false;
try {
conn=con.Connect();
stmt = conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from login where user ='"+user+"' AND password='"+password+"'");
if ( rs.next())
result=true;
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
调用methode
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.out.println("user"+user.getText()+" pass "+password.getText());
boolean Login =m.Authentification(user.getText(), password.getText());
}
错误消息
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Interfaces.Authentification.jButton1ActionPerformed(Authentification.java:215)
at Interfaces.Authentification.access$100(Authentification.java:21)
at Interfaces.Authentification$2.actionPerformed(Authentification.java:84)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)