aspose file tools*
The moose likes JDBC and the fly likes compare resultset values with string value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "compare resultset values with string value" Watch "compare resultset values with string value" New topic
Author

compare resultset values with string value

tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
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



Do Right , Fear No Man
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
Probably because you are using == for comparing two reference types.
tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compare resultset values with string value