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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
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
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.