btnLogIn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try { Connection lig = DriverManager.getConnection(
"jdbc:mysql://localhost/gym", "root", "");
PreparedStatement inst = lig .prepareStatement(
"SELECT * FROM contauser WHERE Username=? AND Password=?");
inst.setString(1, txtUser.getText());
char[] Password=txtPass.getPassword();
inst.setString(2, new String(Password));
int linhas = inst.executeUpdate();
lig.close(); if (linhas == 1) {
JOptionPane.showMessageDialog(frame, "Logged in");
CardLayout card = (CardLayout) frame.getContentPane()
.getLayout();
card.show(frame.getContentPane(), "MenuPrincipal");
}
else JOptionPane.showMessageDialog(frame,
("Invalid username or password"));
} catch (SQLException e1) {
JOptionPane.showMessageDialog(frame,
"Impossível ligar à base de dados");
System.out.println(e1.getLocalizedMessage());
}
}
});
* error
Can not issue executeUpdate () for SELECTs