This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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: 67390
257
  • 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
 
Do not threaten THIS beaver! Not even with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!