This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes User Name and Password Verification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "User Name and Password Verification" Watch "User Name and Password Verification" New topic
Author

User Name and Password Verification

omar salem
Ranch Hand

Joined: Aug 22, 2006
Posts: 34
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


Have a sip of Java !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63232
    
  69

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
omar salem
Ranch Hand

Joined: Aug 22, 2006
Posts: 34
Thanks Bear....Never known about code tags before
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2543
    
  10

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.


OCUP UML fundamental and ITIL foundation
omar salem
Ranch Hand

Joined: Aug 22, 2006
Posts: 34
Thanks for your help.......I really got it to work now...Thanks again
Omar Salem
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: User Name and Password Verification
 
It's not a secret anymore!