HarrJ

Day 26 INSERT INTO query via java

Jul 21st, 2023 (edited)
1,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. package projectSamples;
  2. import java.util.Scanner;
  3.  
  4. public class Day26EmpA {
  5.     //para sa insert
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         Day26Emp callQuery = new Day26Emp();
  9.         String fName, lName, dept, phone, sex, bday;
  10.         double salary;
  11.         int rowsAffected = 0;
  12.        
  13.         System.out.println("***Add new employee***");
  14.         //nilagay sa try catch para pag may maling input, di tutuloy
  15.         try {
  16.             System.out.print("First Name: ");
  17.             fName = sc.nextLine();
  18.             System.out.print("Last Name: ");
  19.             lName = sc.nextLine();
  20.             System.out.print("Dept(ADG/XVN/RTG): ");
  21.             dept = sc.nextLine();
  22.             System.out.print("Phone: ");
  23.             phone = sc.nextLine();
  24.             System.out.print("Sex: ");
  25.             sex = sc.nextLine();
  26.             System.out.print("Salary: ");
  27.             salary = sc.nextDouble();
  28.             sc.nextLine();
  29.             System.out.print("Birthday(YYYY-MM-DD): ");
  30.             bday = sc.nextLine();
  31.  
  32.             rowsAffected = callQuery.addNewEmployee(fName, lName, dept, phone, sex, salary, bday);
  33.         } catch (Exception e) {
  34.            
  35.         }
  36.         if (rowsAffected == 1) {
  37.             System.out.println("New Employee Recorded");
  38.         } else {
  39.             System.out.println("Record Failed");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment