This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Problem while retrieving values from table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem while retrieving values from table" Watch "Problem while retrieving values from table" New topic
Author

Problem while retrieving values from table

Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138
I am storing password in encrypted form in mysql. Now when the user logsin back, I am retrieving those values from the table and comparing those values with the encrypted value of the password of the user who is trying to login but the problem is that I am getting different values from my tables.

I have used rs.getString ("password")
where password is the field name.

This value is in the table
���7�����]�����7vg�
But the retrieved value is
???7???]???7vg?

Why is it so?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14998
    
  27

Because the database is probably using a different character encoding than your Java application. If your encrypted password contains non-text characters, you shouldn't store it in a text-oriented column type (such as VARCHAR) - use a binary column type instead, or convert it to text, for example using Base64 encoding.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14998
    
  27

Please do not post your question in more than one forum.
You also posted this in the Advanced forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while retrieving values from table
 
It's not a secret anymore!