I have to compare user entered id with database id, but I have not get result and unable to return result properly, and can't do this with below code so please tell me how to do
public String execute() throws Exception {
isValid = doProcessing(getUserid());
return SUCCESS;
}
public boolean doProcessing(String userid) throws Exception {
Connection con = null;
// ResultSet rs = null;
PreparedStatement pstmt = null;
boolean status=false;
try {
con = ConnectionDB.createConnection();
pstmt = con.prepareStatement("select userid from attestedform where userid=?");
pstmt.setString(1, userid);
ResultSet rs = pstmt.executeQuery();
request = ServletActionContext.getRequest();
session = request.getSession();
String s = (String) session.getAttribute("UsrBeanLoginId");
while (rs.next()) {
id = rs.getString("userid");
if (s.equalsIgnoreCase(id)) {
status = true;
}
else
{
status=false;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return status;
}
}
You are comparing different value.
I have to compare user entered id with database id
Change your code
while (rs.next()) {
id = rs.getString("userid");
if (userid.equalsIgnoreCase(id)) {
status = true;
}
else
{
status=false;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments