I want to check userid
and password
from database. Is it necessary to store id and password to string first? I am trying to check it by resultset.first()
method as my table has only one row but it is not working.
Asked
Active
Viewed 86 times
-2

Rishav
- 3,818
- 1
- 31
- 49

Dujana Abrar
- 111
- 1
- 8
-
1Your question is too vague to be answered, but I will comment that you should _not_ be storing plain text passwords in your database. – Tim Biegeleisen Mar 13 '18 at 07:16
-
Look into password hashing and salting, never store passwords in plain text. – David Sherman Mar 13 '18 at 07:22
-
`It is not working` is not good description of error. [Here](https://stackoverflow.com/questions/48786813/java-client-authentication-without-a-servlet/48800576#48800576) is my answer about authentication, maybe look there and get your things together. – Piro Mar 13 '18 at 07:23
-
Ok thanks but how can i check userid?? – Dujana Abrar Mar 13 '18 at 07:23
-
@DujanaAbrar if you find userid in your table it is valid. If you do not find it it is invalid. But invalid user id should result in same error as invalid password. – Piro Mar 13 '18 at 07:24
-
I assume your ids and passwords are strings so it makes sense to store them as strings in the database. You can get the user by writing a query that selects the user where id = 'id' and password = 'password'. You should also do a null check if you want to use resultset.first(). – Julius Hörger Mar 13 '18 at 07:28
-
Thanks @JuliusHörger. – Dujana Abrar Mar 13 '18 at 07:32
1 Answers
0
If you have only one row, you can either hash or encrypt the userid-password combination. When user enter the user credentials, hash those details and search in db if its exist or not. If its exist, it will return that row or if its not exist, it will return null.

Anto Livish A
- 322
- 4
- 15