• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

compare resultset values with string value

 
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

 
Marshal
Posts: 70327
283
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic