线程“ AWT-EventQueue-0”中的异常java.lang.NullPointerException登录表单错误

我的代码的目的是打开“ Gestionnaire”窗口或返回错误消息“ Invalid Username / Password”,但是当我单击Login_form中的登录名而不是向我发送错误“ Invalid Username / Password”时,它将返回错误:

线程“ AWT-EventQueue-0”中的异常java.lang.NullPointerException     在javaapplicationhotel2.Login_Form.jButton_LoginActionPerformed(Login_Form.java:426)     在javaapplicationhotel2.Login_Form $ 8.actionPerformed(Login_Form.java:206)     在java.desktop / javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)     在java.desktop / javax.swing.AbstractButton $ Handler.actionPerformed(AbstractButton.java:2308)     在java.desktop / javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)     在java.desktop / javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)     在java.desktop / javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)     在java.desktop / java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)     在java.desktop / java.awt.Component.processMouseEvent(Component.java:6636)     在java.desktop / javax.swing.JComponent.processMouseEvent(JComponent.java:3342)     在java.desktop / java.awt.Component.processEvent(Component.java:6401)     在java.desktop / java.awt.Container.processEvent(Container.java:2263)     在java.desktop / java.awt.Component.dispatchEventImpl(Component.java:5012)     在java.desktop / java.awt.Container.dispatchEventImpl(Container.java:2321)     在java.desktop / java.awt.Component.dispatchEvent(Component.java:4844)     在java.desktop / java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)     在java.desktop / java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)     在java.desktop / java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)     在java.desktop / java.awt.Container.dispatchEventImpl(Container.java:2307)     在java.desktop / java.awt.Window.dispatchEventImpl(Window.java:2762)     在java.desktop / java.awt.Component.dispatchEvent(Component.java:4844)     在java.desktop / java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)     在java.desktop / java.awt.EventQueue $ 4.run(EventQueue.java:721)     在java.desktop / java.awt.EventQueue $ 4.run(EventQueue.java:715)     在java.base / java.security.AccessController.doPrivileged(AccessController.java:391)     在java.base / java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)     在java.base / java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)     在java.desktop / java.awt.EventQueue $ 5.run(EventQueue.java:745)     在java.desktop / java.awt.EventQueue $ 5.run(EventQueue.java:743)     在java.base / java.security.AccessController.doPrivileged(AccessController.java:391)     在java.base / java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)     在java.desktop / java.awt.EventQueue.dispatchEvent(EventQueue.java:742)     在java.desktop / java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)     在java.desktop / java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)     在java.desktop / java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)     在java.desktop / java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)     在java.desktop / java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在java.desktop / java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

这是我的代码:

    PreparedStatement st;
    ResultSet rs;

    // donnez l'username et le password 
    String username = jTextField_Username.getText();
    String password = String.valueOf(jPasswordField.getPassword());

    // requete indiquant si les identifiants existent 
    String query = "SELECT * FROM 'users' WHERE 'username' = ? AND 'password' = ?";


    try {
        st = (PreparedStatement) Connecter.getConnection().prepareStatement(query);

        st.setString(1, username);
        st.setString(2, password);
        rs = st.executeQuery();

        if(rs.next())
        {
            //ouvrir le gestionnaire 
            Gestionnaire form = new Gestionnaire();
            form.setVisible(true);
            form.pack();
            form.setLocationRelativeTo(null);

            this.dispose();

        }else{
            //erreur  
            JOptionPane.showMessageDialog(null, " Invalid Username / Password", "Login Error",2);
        }

    } catch (SQLException ex) {
        java.util.logging.Logger.getLogger(Login_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }

这是我的连接器:

package javaapplicationhotel2;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.sql.*;

/**
 *
 * @author camil
 */




public class Connecter {

  public static Connection getConnection() {
    return con;
}
static Connection con; 


    public Connecter() {
      try{
      Class.forName("com.mysql.cj.jdbc.Driver");
      }catch(ClassNotFoundException e){
          System.err.println(e);


    }
    try{
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/hotel","root","");
    }catch(SQLException e){System.err.println(e);}
    }
    Connection obtenirconnexion(){return con;}

    PreparedStatement prepareStatement(String select__from_classe) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.



    }


}