我现在面临一个问题,即将我的登录数据输入与我的数据库java DB进行比较。
这是我进行比较的代码
尝试{
Statement st = theConnection.createStatement();
strr = ("SELECT DEMO.REGISTRATION.*,
DEMO.STUDENT.STUD_PASSWORD,DEMO.LECTURER.LECT_PASSWORD FROM DEMO.REGISTRATION LEFT OUTER JOIN DEMO.STUDENT ON REGISTRATION.STUDENT_ID = STUDENT.STUDENT_ID ON REGISTRATION.LECTURER_ID = LECTURER.LECTURER_ID;");
ResultSet rs = st.executeQuery(strr);
String m = matricI;
String p = passwordI;
while (rs.next()) {
String matricS = rs.getString(2);
String passwordS = rs.getString(4);
String matricL = rs.getString(3);
String passwordL = rs.getString(5);
if(m.equals(matricS) && p.equals(passwordS)){
response.sendRedirect("StudentInput");
return;}
else {
out.println("<p class=\"bg-danger container\">Sila masukkan No. Matrik dan Kata Laluan yang betul !</p>");
}
if(m.equals(matricL) && p.equals(passwordL)){
response.sendRedirect("Lecturer.html");
return;}
else {
out.println("<p class=\"bg-danger container\">Sila masukkan No. Matrik dan Kata Laluan yang betul !</p>");
}
}
}