-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUserView.java
More file actions
70 lines (65 loc) · 1.81 KB
/
UserView.java
File metadata and controls
70 lines (65 loc) · 1.81 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.sql.SQLException;
import java.util.Scanner;
public class UserView {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("1. Login");
System.out.println("2. Register");
System.out.println("Enter the Choice ");
Scanner scanner= new Scanner(System.in);
int choice = scanner.nextInt();
if(choice ==2){
System.out.println("Enter the Userid ");
String userid = scanner.next();
System.out.println("Enter the Password");
String password = scanner.next();
UserDTO userDTO = new UserDTO();
userDTO.setUserid(userid);
userDTO.setPassword(password);
UserDAO dao = new UserDAO();
try {
String status = dao.register(userDTO);
if(status.equals(StatusConstants.SUCCESS)){
System.out.println("user register....");
}
else
{
System.out.println("Can't Register");
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
if(choice ==1){
System.out.println("Enter the Userid ");
String userid = scanner.next();
System.out.println("Enter the Password");
String password = scanner.next();
UserDTO userDTO = new UserDTO();
userDTO.setUserid(userid);
userDTO.setPassword(password);
UserDAO dao = new UserDAO();
try {
String status = dao.login(userDTO);
if(status.equals(StatusConstants.SUCCESS )){
System.out.println("Welcome "+userid);
}
else
{
System.out.println("Invalid Userid or Password...");
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}