0

I'm trying to connect the SQL plus database with java but it's not working , I'm using netbeabs ide 8.0.2 Here i have pasted following cod

e in my submit button but when I execute it then it goes for the JOptionPane which is in else part whereas it should go for the if part. I'm working on it but I've got no solution can u help please

String sql ="select * from ADMINTABLE where APOST = ? and USERNAME = ? and PASSWORD = ?";
try {
    pst = con.prepareStatement(sql)
          pst.setString(1, jComboBox1.getSelectedItem().toString());
    pst.setString(2,jTextField1.getText());
    pst.setString(3, Arrays.toString(jPasswordField1.getPassword()));
    rs = pst.executeQuery();
    if (rs.next()) {
        rs.close();
        pst.close();
        con.close();
        setVisible(false);
        Admin ob = new Admin();
        ob.setVisible(true);
    } else
        JOptionPane.showMessageDialog(null,"username and password not matched Please Enter Again !!!");
} catch (SQLException e) {
    JOptionPane.showMessageDialog(null,e);
}
3
  • Please fix formatting. Commented Oct 4, 2018 at 13:35
  • done ! please have a look on the code hope u can solve my problem Commented Oct 4, 2018 at 13:46
  • It seems you are storing the password in plain text. Since this is highly insecure, I would suggest to hash the password instead. Commented Oct 4, 2018 at 14:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.