Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

User Name and Password Verification

 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am trying to validate a user name and a password by comparing details in the database with those provided by the user inside the text fields of the simple frame created for this test. the condition gets always true even if the entries do not match details from the database and always gives me the message "Match Found". Here is the code i worte for this :


I would appreciate your help and fast response.
Omar Salem
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65339
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear....Never known about code tags before
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to print out all the values, and compare for yourself.


Some comments: do not use


You could simplify your code by using a where clause:
Bind your username and password using a PreparedStatement in stead of a Statement, and execute it.

If your query returns anything (next() == true), then you have a match.
No need to retrieve all possible records, and looping over them.

You could increase security of your code by searching for a good security mechanism. Your mechanism sends readable user name and password over the network.
 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help.......I really got it to work now...Thanks again
Omar Salem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic