-
Notifications
You must be signed in to change notification settings - Fork 0
/
Authentication.java
36 lines (31 loc) · 1.02 KB
/
Authentication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//Authentication
import java.io.*;//for taking inputs at runtime
import java.sql.*;//for Query
class Authentication
{
//BufferedReader is a perdefined class used to take runtime input.
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public int ValidateUser()//A function created of Int type.
{
int t=0;//initially transaction(t)=0;
try
{
System.out.println("Enter UserId:");
String Userid=br.readLine();//readLine() is used to all inputs except characters
System.out.println("Enter PASSWORD:");
String Password=br.readLine();
connect c=new connect();
Connection con=c.fetchcon();
Statement stmt=con.createStatement();
String q1="select*from Bank_Authentication where UserId='"+Userid+"'and Password='"+Password+"'";
ResultSet rs=stmt.executeQuery(q1);
if(rs.next())
t=1;
con.close();
}
catch(Exception e)
{}
return t;
}
}
//AFTER EXECUTION ONLY CASE SENSITIVE IS THE PASSWORD AND USERID IN TERMS OF CASES THAT IS UPPER OR LOWER:)