我有一個需要用戶名,密碼和ID的登錄系統。數據庫中的密碼以MD5格式加密。我的測試密碼是test1
,加密後是5a105e8b9d40e1329780
。登錄屏幕上的用戶應該輸入test1
作爲密碼並允許進入系統。我只是不斷收到我的消息。Java中的SQL。選擇密碼(md5)問題。 rs不執行查詢,拋出異常
我的SQL查詢看起來是這樣的:
String SQL = "SELECT login_judge.username, login_judge.password ,criminalrecords.ID FROM login_judge, criminalrecords "
+ "WHERE username = ? and password = md5(?) and ID = ?";
pst = conn.prepareStatement(SQL);
pst.setString(1, usernameF.getText());
pst.setString(2, passwordF.getText());
pst.setString(3, caseNoF.getText());
rs = pst.executeQuery();
if(rs.next())
{
// rest of code
}
else
{
// joption pane displaying info that something is wrong.
}
從phpMyAdmin的
UPDATE `w1283057`.`login_judge` SET `password` = MD5( 'test1') WHERE `login_judge`.`username` = 'test1';
什麼是你蹦出來的消息? – 2013-03-22 15:17:42
@SotiriosDelimanolis它只是JOptionPane。「細節錯誤/不匹配系統記錄」或多或少像這樣 – 2013-03-22 15:18:39
然後,你的數據庫中沒有這樣的用戶。當你插入用戶時,你是否使用md5來散列密碼? – 2013-03-22 15:19:13