1777350 Members
3018 Online
109069 Solutions
New Discussion юеВ

java resultset

 
Piotr Kirklewski
Super Advisor

java resultset

Hi there

I have a strange problem with my Java app.
I'm testing if username and password is correct and retrieve 1 or 0.
But when I test with if (a == "1") then I get negative response as if the value stored in 'a' doesn't match.
I debugged the application but debugger shows a = "1" so I'm completely stupefied by this.
Please help.

===============================================

Statement select = c.createStatement();
ResultSet result = select.executeQuery("select count(*) from system_user where nm = '"
+ username + "' and pwd = '" + password + "'");


if (result != null) {
System.out.println("result !null");
while (result.next()) {
a = result.getString(1);
System.out.println(a);

if (a == "1"){
System.out.println(result.getString(1) + "Access granted");
}

}
}

if (a == "1"){
System.out.println("Access granted !!!");

}else{
System.out.println("User " + username + " does not exists in the databse!!!");
}

result.close();
Jesus is the King
2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: java resultset

Any embedded nulls? What is the length?
What version of Java?
Piotr Kirklewski
Super Advisor

Re: java resultset

Nothing that I know of.

java version "1.6.0_14"
Jesus is the King