Trouble with the output with same program on different computer
"Kaizar" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <[email protected]> |
Used the below coding in a login form button. Its running completely fine on the computer it was developed on but not on the other computer. The database is same on both computers. Its showing a message "Username and/or Password don't match the Database!" but when I displayed the data that I got from db, everything is fine but still its showing the message instead of opening the other form
Code:
String user = userTF.getText();
String pass = passTF.getText();
String sql="Select * from employeetable";
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con= (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/leicesterfloors","root","5618");
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
int tmp=0;
while(rs.next()) {
String uname=rs.getString("emp_code");
String password=rs.getString("Password");
String first = rs.getString("First_name");
String sur = rs.getString("surname");
String name = first+" "+sur;
if ((user.equals(uname)) && (password.equals(pass))) {
MainPage main = new MainPage();
main.user(name);
main.setVisible(true);
dispose();
tmp++;
}
}
if (tmp==0) {
JOptionPane.showMessageDialog(null, "Username and/or Password don't match the Database!");
}
}
catch ( ClassNotFoundException | SQLException e){
JOptionPane.showMessageDialog(this, e.getMessage());
}
// TODO add your handling code here:
}
private void anuBtnActionPerformed(java.awt.event.ActionEvent evt) {
adminTF.setText("");
passTF1.setText("");
jDialog1.setVisible(true);
// TODO add your handling code here:
}
private void levelTFKeyTyped(java.awt.event.KeyEvent evt) {
confirmBtn.setEnabled(true);