为什么即使输入了正确的密码,以下代码也会显示错误?
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:mydsn","sa","password@123");
String sql = "select customer_id, fname, lname, email_id, phone_number from customer_details where user_name=? and password=?";
PreparedStatement stmt;
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
session.setAttribute("customerId", rs.getString(1));
session.setAttribute("userName", userName);
session.setAttribute("fName", rs.getString(2));
session.setAttribute("lName", rs.getString(3));
session.setAttribute("emailId", rs.getString(4));
session.setAttribute("phoneNumber", rs.getString(5));
conn.close();
%>
<jsp:forward page="welcome.jsp" />
<%} else {%>
Sorry! You have entered an invalid username or password. Please try again.
<%}
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}