Hi Ranch,
I am developing standalone GUI bank application
in the log in window the action i am trying to perform for the jButton1 is that when the user enters the UserId and Password and hit the Submit Button the following is expected
1)the database i am using is MsAccess 2007
2) when user hits the submit button then userid and password should be search and if it is there then user gets to next window
3)otherwise a dialog box should be displayed
But the result i am getting
1) when the user enters the UserId and Password and hit the Submit Button i am not getting the desired output because i think the sql query i am using is not executing at all.
SQL Query----("Select UserID,Password "+"From LoginInformation where UserID='"+i+"' and Password='"+j+"'");
kindly suggest on this and also the flaw if any is there in query
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String i = jTextField1.getText();
String j = jTextField2.getText();
try {
pstmt = con.prepareStatement("Select UserID,Password "+"From LoginInformation where UserID='"+i+"' and Password='"+j+"'");
/*pstmt.setString(1, i);
pstmt.setString(2, j);*/
rs = pstmt.executeQuery();
while (rs.next()) {
if (rs.getString(1).equals(i) && rs.getString(2).equals(j)) {
HomePage hp = new HomePage();
hp.setVisible(true);
close();
} else if (i.isEmpty() || j.isEmpty()) {
JOptionPane.showMessageDialog(null, "UserId and password cannot be left blank.");
} else {
JOptionPane.showMessageDialog(null, "Enter Correct UserId and Password");
}
}
} catch (Exception e) {
}
}
Thanks