This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes comparing values from database and from a textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "comparing values from database and from a textbox" Watch "comparing values from database and from a textbox" New topic
Author

comparing values from database and from a textbox

abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66


The thing is its not going inside the give if loop,however all the 4 values str1,str2,val1,val2 are being printed correctly.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You are comparing strings using "==" ?


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

And please UseCodeTags the next time you want to post some code.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Please try using: if ( val1.equals(str1)) instead of if ( val1==str1). The former will check for the similarity of the values but the latter will only check if both the variables point/refer to the same string.


Mohamed Sanaulla | My Blog
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Mohamed Sanaulla wrote:Please try using: if ( val1.equals(str1)) instead of if ( val1==str1). The former will check for the similarity of the values but the latter will only check if both the variables point/refer to the same string.

I wish the original poster would have figured that by himself...
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
ok ,i got that.Thank you Christophe Verré and Mohamed Sanaulla
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Christophe Verré wrote:
Mohamed Sanaulla wrote:Please try using: if ( val1.equals(str1)) instead of if ( val1==str1). The former will check for the similarity of the values but the latter will only check if both the variables point/refer to the same string.

I wish the original poster would have figured that by himself...


Yeah, my mistake. I realized after posting the reply
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
its working.Actually i am creating a desktop application,i have create a login panel ,what i want is to navigate from this login panel to other panel.
 
wood burning stoves
 
subject: comparing values from database and from a textbox
 
Similar Threads
retrieving value from a text box
Error in output
Navigating data using JDBC and SQLServer 2005
doubt in update
Setting the attribute