wood burning stoves 2.0*
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
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: 60782
    
  65

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: 2491
    
    8

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
youtube channel
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: User Name and Password Verification
 
Similar Threads
Setting Focus on Enter key pressed
java .lang .Number Format Error
JApplet not connecting to SQL database
retrieved data from database and tick JTextBox in my form automatically
struts form beans