Re: How to make getText() return the result in case sensitive ?
Problem solved ! It runs well as I need. Thank you for your help. Here
the code :
@Action public void doLogin() {
String url = "jdbc:mysql://localhost:3306/dicom?
jdbcCompliantTruncation=false";
Connection con;
PreparedStatement passwordLookup ;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.println(e);
}
try {
con = DriverManager.getConnection(url, "root", "");
String sql = "SELECT userid,passwd FROM user WHERE userid
= BINARY ? AND passwd = BINARY ?";
passwordLookup = con.prepareStatement(sql);
char[] passwdnya = passwdTxt.getPassword();
String convertedChars = new String(passwdnya);
passwordLookup.setString(1, userIDTxt.getText().trim());
passwordLookup.setString(2, convertedChars.trim());
ResultSet result = passwordLookup.executeQuery();
if (result.next()) {
String dbUsername = result.getString("userid") ;
String dbPassword = result.getString("passwd") ;
if ((dbUsername.equals(userIDTxt.getText().trim()))
&& (dbPassword.equals(convertedChars.trim()))){
setVisible(false);
if (ecgMenuBox == null) {
JFrame mainFrame =
Main.getApplication().getMainFrame();
ecgMenuBox = new ECGMenu(mainFrame);
ecgMenuBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(ecgMenuBox);
}
else {
setVisible(false);
if (loginWarningBox == null) {
JFrame mainFrame =
Main.getApplication().getMainFrame();
mainFrame.setSize(100,80);
loginWarningBox = new
LoginWarning(mainFrame);
loginWarningBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(loginWarningBox);
}
}
else {
setVisible(false);
if (loginWarningBox == null) {
JFrame mainFrame =
Main.getApplication().getMainFrame();
mainFrame.setSize(100,80);
loginWarningBox = new
LoginWarning(mainFrame);
loginWarningBox.setLocationRelativeTo(mainFrame);
}
Main.getApplication().show(loginWarningBox);
}
result.close();
passwordLookup.close();
con.close();
} catch(SQLException e) {
System.err.println(e);
}
}