B
balgach
Hello all, i am trying to compare two exact strings and seem to be
failing at it, and just wondering what i am doing wrong. basically i
have a postgresql table:
foo(t1, t2); both t1 and t2 are of type char(20).
when i do in postgresql a: select t1 from foo where t2='bla'; it
returns one tuple with the value "test" now here is my java code:
ResultSet results = sql.executeQuery("select t1 from foo where
t2='bla'");
String _t = "test";
if (results != null) {
results.next();
System.out.println(results.getString(1)+"\n");
String _s = new String(results.getString(1));
if (_s==_t)
System.out.println("Matched\n");
else
System.out.println("NO MATCH\n");
}
results.close();
}
it returns the right thing (a string that says "test") in the
System.out line, but the comparison keeps sending me to the else
statement, not the first one. anyone know why?
Cheers,
Adam.
failing at it, and just wondering what i am doing wrong. basically i
have a postgresql table:
foo(t1, t2); both t1 and t2 are of type char(20).
when i do in postgresql a: select t1 from foo where t2='bla'; it
returns one tuple with the value "test" now here is my java code:
ResultSet results = sql.executeQuery("select t1 from foo where
t2='bla'");
String _t = "test";
if (results != null) {
results.next();
System.out.println(results.getString(1)+"\n");
String _s = new String(results.getString(1));
if (_s==_t)
System.out.println("Matched\n");
else
System.out.println("NO MATCH\n");
}
results.close();
}
it returns the right thing (a string that says "test") in the
System.out line, but the comparison keeps sending me to the else
statement, not the first one. anyone know why?
Cheers,
Adam.