Não sei oque pode estar acontecendo no comando do meu botão de Login, onde ele faz a verificação no BD. Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException. Não consigo sair deste erro.
Button LoginButton = new Button(“Login”);
LoginButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Connection c = PoolConnection.getInstance().getConnection();
String sql = "SELECT * FROM Usuario where usuario=? and senha=?";
PreparedStatement stmt = c.prepareStatement(sql);
stmt.setString(1, tfLogin.getText());
stmt.setString(2, new String(lPasswordField.getPassword()));
ResultSet rs = stmt.executeQuery();
if(rs.next()) {
Menu exibir = new Menu();
exibir.setVisible(true);
setVisible(false);
}else {
JOptionPane.showMessageDialog(null, "Usuario/Senha Incorretos");
}
stmt.close();
c.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
});
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at janela.Login$2.actionPerformed(Login.java:87)
at java.desktop/java.awt.Button.processActionEvent(Button.java:411)
at java.desktop/java.awt.Button.processEvent(Button.java:379)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)