Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.Scanner;
- import java.sql.*;
- public class Authentication {
- public static final Scanner input = new Scanner(System.in);
- public static final String url="jdbc:mysql://localhost:3306/patient_registration_system?autoReconnect=true&useSSL=false";
- public static final String urlname = "root";
- public static final String password = "root";
- public static final String query = "SELECT * FROM patient_registration_system.authentication;";
- void checking() throws Exception {
- String name = null;
- int id = 0;
- String ans = null;
- //Name input
- System.out.print("t Please enter your name : ");
- try {
- name = input.next();
- }
- catch (InputMismatchException e) {
- System.out.println("Error. Please enter your name which is suppose to be only words.");
- checking();
- }
- System.out.println();
- //id number input
- System.out.print("t Please enter your id number : ");
- try {
- id = input.nextInt();
- }
- catch (InputMismatchException e) {
- System.out.println("Error. Please enter only numbers");
- checking();
- }
- System.out.println();
- if(checkingDAO(id,name) == 1) {
- System.out.println("t Welcome");
- }
- else {
- System.out.println("tYour Id and name does not match with our system.");
- System.out.print("tDo you want to try again? : ");
- ans = input.next();
- ans.toLowerCase();
- while (ans.equals("yes") || ans.equals("y")) {
- checking();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement