Advertisement
Guest User

Untitled

a guest
Oct 8th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner;
  3. import java.sql.*;
  4.  
  5. public class Authentication {
  6.  
  7. public static final Scanner input = new Scanner(System.in);
  8. public static final String url="jdbc:mysql://localhost:3306/patient_registration_system?autoReconnect=true&useSSL=false";
  9. public static final String urlname = "root";
  10. public static final String password = "root";
  11. public static final String query = "SELECT * FROM patient_registration_system.authentication;";
  12.  
  13. void checking() throws Exception {
  14.  
  15. String name = null;
  16. int id = 0;
  17. String ans = null;
  18.  
  19. //Name input
  20. System.out.print("t Please enter your name : ");
  21. try {
  22. name = input.next();
  23. }
  24. catch (InputMismatchException e) {
  25. System.out.println("Error. Please enter your name which is suppose to be only words.");
  26. checking();
  27. }
  28. System.out.println();
  29.  
  30. //id number input
  31. System.out.print("t Please enter your id number : ");
  32. try {
  33. id = input.nextInt();
  34. }
  35. catch (InputMismatchException e) {
  36. System.out.println("Error. Please enter only numbers");
  37. checking();
  38. }
  39. System.out.println();
  40.  
  41. if(checkingDAO(id,name) == 1) {
  42. System.out.println("t Welcome");
  43. }
  44. else {
  45. System.out.println("tYour Id and name does not match with our system.");
  46. System.out.print("tDo you want to try again? : ");
  47. ans = input.next();
  48. ans.toLowerCase();
  49. while (ans.equals("yes") || ans.equals("y")) {
  50. checking();
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement