Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void KPA_buttonLoginActionPerformed(java.awt.event.ActionEvent evt) {
- {
- try
- {
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- String url="jdbc:sqlserver://localhost:1433;databaseName=KeyProp;user=sa;password=Password1@";
- Connection con = DriverManager.getConnection(url);
- String sql = "Select * from Authentication where Username = ? and Password = ?";
- String usernameString = "Select * from Authentication where Username = Donovan";
- PreparedStatement pst = con.prepareStatement(sql);
- PreparedStatement usernamePst = con.prepareStatement(usernameString);
- pst.setString(1,KPA_tfUsername.getText());
- pst.setString(2,KPA_pfPassword.getText());
- usernamePst.setString(3,KPA_tfUsername.getText());
- ResultSet rs = pst.executeQuery();
- ResultSet usernameRs = usernamePst.executeQuery();
- while (usernamePst.getString(3) = 'Test')
- {
- if (rs.next())
- {
- JOptionPane.showMessageDialog(null, "Username and Password Matched");
- KeyProp_LaunchPage kplp = new KeyProp_LaunchPage();
- kplp.setVisible(true);
- setVisible(false);
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Username and Password not Correct");
- KPA_tfUsername.setText("");
- KPA_pfPassword.setText("");
- KeyProp_LaunchPage kpl = new KeyProp_LaunchPage();
- kpl.setVisible(false);
- setVisible(true);
- }
- con.close();
- }
- }
- catch(Exception e)
- {
- JOptionPane.showMessageDialog(null, e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement