Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compare resultset values with string value

 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code is wriiten so that it will chec whether the username value is present in result set or not .
rs1 is result set .
username value is given "SMITH" & the result set is the set of "ename" from emp table in oracle db.
in line 4 i have checked the value of username is "SMITH" which i have passed before .
my problem is the condition always evaluates to false , but it should be true , maybe the comparision in line 5 is not right, is it required to convert the "rs1.getString(i)" to string . i am a bit confused how can i search for username in resultset

 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably because you are using == for comparing two reference types.
 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Probably because you are using == for comparing two reference types.


thanks for the answer ,
but still i cannot understand how to compare , it would be great if you can show me some code.
one more thing , result set is in string format but what happens when i am comparing it.

Regards
TUSHAR
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic