• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Verifying Username & Password

 
Ranch Hand
Posts: 35
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:-

 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 35
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic