Boa noite como faço para criar este método no Dao e só chamar o nome?
private void jButton_LoginActionPerformed(java.awt.event.ActionEvent evt) {
Connection con = ConnectionFactory.getConnnection();
String sql = "SELECT login, senha FROM tbl_login WHERE login=? AND senha=? ";
PreparedStatement pst = null;
ResultSet rs =null;
try {
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_login", "root", "123");
pst = con.prepareStatement(sql);
pst.setString(1, jTextField_Username.getText());
pst.setString(2, String.valueOf(jPasswordField_Password.getPassword()));
rs = pst.executeQuery();
if(rs.next()){
JOptionPane.showMessageDialog(null,"username and password matched");
jLabel_Message.setText("Login Successfully");
jLabel_Message.setForeground(Color.GREEN);
timer1.start();
new MenuView().setVisible(true);
}else{
JOptionPane.showMessageDialog(null, "username and password do not matched");
jLabel_Message.setText("Invalide Username Or Password !!");
jLabel_Message.setForeground(Color.RED);
timer1.start();
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null,ex);
}
}
