Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class loginButton implements ActionListener{
- public void actionPerformed(ActionEvent e) {
- Connection connection;
- PreparedStatement ps;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/userlist", "root", "Hadasada3!");
- ps = connection.prepareStatement("SELECT `username`, `password` FROM `userlist` WHERE `username` = ? AND `password` = ?");
- ps.setString(1, textUsername.getText());
- ps.setString(2, String.valueOf(textPassword.getPassword()));
- ResultSet result = ps.executeQuery();
- if(result.next()){
- JOptionPane.showMessageDialog(null, "Login Success.");
- String[] args = null;
- CowboyCorral.main(args);
- dispose();
- }
- else{
- JOptionPane.showMessageDialog(null, "Login Failed.");
- }
- } catch (SQLException ex) {
- Logger.getLogger(CCLogin.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- buttonLogin.addActionListener(new loginButton());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement