daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest May 16th, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class DBManager {
  2.    
  3.       public HashMap<String, Staff> loadStaff()
  4.     {
  5.         HashMap<String, Staff> staff = new HashMap<String, Staff>();
  6.        
  7.         try
  8.         {
  9.             Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  10.             Connection conn = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\Ryan\\Desktop\\Graded Unit\\PaRkEaSyPrOjEcT\\ParkEasyAirportParking\\lib\\BookingDB.accdb");
  11.        
  12.             Statement stmt = conn.createStatement();
  13.             ResultSet rs = stmt.executeQuery("SELECT * FROM Staff");
  14.            
  15.             while(rs.next())
  16.             {
  17.                
  18.                 String firstName = rs.getString("FirstName");
  19.                 String lastName = rs.getString("LastName");
  20.                 String password = rs.getString("Password");
  21.                 String phoneNumber = rs.getString("PhoneNumber");
  22.                 String mobileNumber = rs.getString("MobileNumber");
  23.                 String email = rs.getString("Email");
  24.                 String postcode = rs.getString("PostCode");
  25.                 String town = rs.getString("Town");
  26.                 String street = rs.getString("Street");
  27.                 String houseNo = rs.getString("HouseNo");
  28.                 int staffID = rs.getInt("StaffID");
  29.                 boolean isStaff = rs.getBoolean("IsStaff");
  30.                
  31.                 Staff s = new Staff(staffID, isStaff, firstName, lastName, password, phoneNumber, mobileNumber, email, postcode, town, street, houseNo);
  32.                 staff.put(email, s);
  33.             }
  34.             return staff;
  35.         }
  36.         catch(Exception ex)
  37.         {
  38.             return staff;
  39.         }      
  40.     }
  41.      
  42.     public HashMap<String, Customer> loadCustomers()
  43.     {
  44.         HashMap<String, Customer> cust = new HashMap<String, Customer>();
  45.        
  46.         try
  47.         {
  48.             Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  49.             Connection conn = DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\Ryan\\Desktop\\Graded Unit\\PaRkEaSyPrOjEcT\\ParkEasyAirportParking\\lib\\BookingDB.accdb");
  50.        
  51.             Statement stmt = conn.createStatement();
  52.             ResultSet rs = stmt.executeQuery("SELECT * FROM Customers");
  53.            
  54.             while(rs.next())
  55.             {
  56.                 int customerID = rs.getInt("CustomerID");
  57.                 String firstName = rs.getString("FirstName");
  58.                 String lastName = rs.getString("LastName");
  59.                 String password = rs.getString("Password");
  60.                 String phoneNumber = rs.getString("PhoneNumber");
  61.                 String mobileNumber = rs.getString("MobileNumber");
  62.                 String email = rs.getString("Email");
  63.                 String postcode = rs.getString("PostCode");
  64.                 String town = rs.getString("Town");
  65.                 String street = rs.getString("Street");
  66.                 String houseNo = rs.getString("HouseNo");
  67.                
  68.                 Customer c = new Customer(customerID, firstName, lastName, password, phoneNumber, mobileNumber, email, postcode, town, street, houseNo);
  69.                 cust.put(email, c);
  70.             }
  71.             return cust;
  72.         }
  73.         catch(Exception ex)
  74.         {
  75.             return cust;
  76.         }      
  77.     }
RAW Paste Data
Top