JOptionPane 没有显示..请检查我的代码:
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//if (e.getActionCommand().equals("Ok")){
if ( e.getActionCommand().equals(btnOk) ){
if(connect(txtUser.getText(), txtPass.getText() ) ) {
JOptionPane.showMessageDialog(null, "WARNING", "Valid user!", JOptionPane.INFORMATION_MESSAGE);
}
else {
System.out.print("Wrong password!");
}
}
}
我的连接方法,请检查这个。
public boolean connect(String usr, String pwd){
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/USERS", "root", "root" );
PreparedStatement ps =
connection.prepareStatement( "SELECT lname, fname FROM employees where fname=? and lname =?" );
ps.setString(1,usr);
ps.setString(2,pwd);
resultSet = ps.executeQuery();
if(resultSet.next()) {
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
} // end of connect method
我不知道我的代码有什么问题。任何帮助,将不胜感激。谢谢