Link to home
Create AccountLog in
Avatar of mateusrm
mateusrm

asked on

Validating a user in the database

Hello, I have a table on a database with usernames. So, I want to check the user on a String with the user on the database to see if it is valid. I already did the connection with the database.
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of durgaprasad_j
durgaprasad_j

Hi ,
 I didn't get exactly what you want.
 suppose if the schema of table is  Username, password
 then use this query : select Username from usernames where Username="<Somename>" and password ="<somepassword>";

 If the resultSet contains any results, It means user is there. If there are no results, user is not valid.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
durgaprasad_j all that you say is correct. However this is exactly what a JDBC realm does. Instead of having to write all this piece of code yourself, you create the realm and define it in the web.xml (or any other server-specific file) and you are set. You leave the rest to the web server.
listening
All quite valid inputs