Boolean function not returning proper value
I am using following function which uses boolean value.
int recFound=0;
public Boolean CheckUser(String uName,String password)
{
try
{
statement=conn.createStatement();
resultSet=statement.executeQuery("select count(*) from
UserMaster where username LIKE'"+uName+"' and password
LIKE'"+password+"'");
if(resultSet.getRow()>0)
{
recFound=1;
}
else
{
recFound=0;
}
}
catch (Exception e) {
e.printStackTrace();
recFound=0;
}
if(recFound == 0)
{
return false;
}
else
{
return true;
}
}
I am calling this function through:
boolean isValidUser=con.CheckUser(etLoginID.getText().toString(),
etPassword.getText().toString());
if(isValidUser)
{
Intent i= new
Intent(getApplicationContext(),Messages.class);
startActivity(i);
}
When i pass this function proper values its not making recFound=1;
And in last condition although recFound==0 it enters in else condition and
returns true.
But while assigning this value to caller functions return value it assigns
false.
Means it makes , boolean
isValidUser=con.CheckUser(etLoginID.getText().toString(),
etPassword.getText().toString()); to be false.
isValidUser should get true in such case.
Please help me.
No comments:
Post a Comment