package jdbcassignment;
import java.sql.*;
import java.util.Scanner;
public class RetrieveStudentDataFromConsole {
    public static void main (String [] args) throws  Exception{

        Scanner sc = new Scanner(System.in);

        Connection connection=null;
        Statement statement =null;
        ResultSet resultSet = null;

        String url ="jdbc.mysql://localhost:3306/firstDBPractice";
        String userName="root";
        String mysqlPassword ="nisum123";

        System.out.print("Enter Your Name Here .... ");
        String name = sc.nextLine();
        System.out.print("Enter Your Roll No ................");
        String roll_no = sc.nextLine();

        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/firstDBPractice","root","nisum123");
            statement = connection.createStatement();
            resultSet = statement.executeQuery("select * from Employee");

            while(resultSet.next()){
                if(resultSet.getString("emp_name").equals(name) || resultSet.getString("emp_id").equals(roll_no)){
                    System.out.println("Your Name is  ----- Mr "  + name + " And Your id Is ------ " + roll_no);
                }
            }

        }
        catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
}