File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Verifying Username & Password Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Verifying Username & Password" Watch "Verifying Username & Password" New topic
Author

Verifying Username & Password

Ranjeet Deshmukh
Greenhorn

Joined: Jan 18, 2013
Posts: 24

Hi All,

I'm doing JDBC with Mysql 5.2, I'm storing my password using md5 encryption. Program should show error message when password entered from command line is not matched with password stored in DB. Tell me what will to replace "?" in if().

My code is:-



~R@njeet.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38064
    
  22
Why are you using a password without a user name? Why are you showing the password in clear on the command terminal? Why have you got the root password unencrypted in that code? Why have you got pairs of variables which differ only in the case of their first letter?
Ranjeet Deshmukh
Greenhorn

Joined: Jan 18, 2013
Posts: 24

Campbell Ritchie wrote:Why are you using a password without a user name? Why are you showing the password in clear on the command terminal? Why have you got the root password unencrypted in that code? Why have you got pairs of variables which differ only in the case of their first letter?



This is just a basic program, I'm accepting password and if it is correct then I'm greeting the user with username associated with password and if password is wrong then displaying an error message. "Password" is accepting the password from user at CL and "password" contains the root password for Mysql.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38064
    
  22
You would have to check the password against those retrieved. If it is an MD5, what form does it return the result in? Is it a BigInteger? Use its equals() method. What you are doing is working out an existential quantification
x • MD5(x) ∈ passwordMD5s
What you ought to do is use a password field or the Console class’ method for password, and ask for user name and password before you set up the connection at all. Don’t use the root password.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Verifying Username & Password
 
Similar Threads
Reading from XML file
running a batch file from java
prog of multiple inputs
Verification of Password in JDBC
we ask for user input in c by writing & (ampersand) but how to achieve this in java ?