• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

user authentication

 
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a user table that contains three columns: username, password, and fullname. The fullname will be used to greet the user. The password is hashed before put in the table. Which one is the better way:

Method 1:
The query is
If the query doesn't return a row it means the username given is wrong.
If it does, then we compare the password we get from the database with the one given by user.

OR

Method 2:
The query is
If the query doesn't return a row it means either the username or the password are wrong.

?
[ May 16, 2005: Message edited by: Yosi Hendarsjah ]
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yosi!

even though either of them will work, the second seems to be more effective as the username-pw combination needs to be matched

cheers
 
author & internet detective
Posts: 39655
785
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yosi,
I agree that option 2 is better. There is less network traffic.

Even better is to use a PreparedStatement so the sql is only compiled once.
 
Yosi Hendarsjah
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Amarender and Jeanne!
Your opinion is the same as I thought. I even use the PreparedStatement.

yosi
 
It's exactly the same and completely different as this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!