Пример #1
0
 public int insertDriver() throws SQLException {
   connect();
   Statement statement = connection.createStatement();
   String query =
       "INSERT INTO `Drivers` (`driverID`, `firstName`, "
           + " `lastName`, `address`, `phone`, `email`, `cvName`, `dateAdded`,"
           + " `idNumber`, `subcountyID`)"
           + " VALUES (\""
           + driver.getUserID()
           + "\", \""
           + driver.getFirstName()
           + "\",\""
           + driver.getLastName()
           + "\", \""
           + driver.getAddress()
           + "\", "
           + "\""
           + driver.getPhone()
           + "\", \""
           + driver.getEmail()
           + "\", \""
           + driver.getCvName()
           + "\", \""
           + driver.getDateAdded()
           + "\", \""
           + driver.getIdNumber()
           + "\", \""
           + driver.getSubcounty().getSubcountyID()
           + "\")";
   int result = statement.executeUpdate(query);
   disconnect();
   return result;
 }
Пример #2
0
 public boolean driverExists() throws SQLException {
   connect();
   boolean exists = false;
   Statement statement = connection.createStatement();
   String query =
       "SELECT `driverID` FROM `Drivers` WHERE "
           + "`address` = \""
           + driver.getAddress()
           + "\" OR "
           + "`email` = \""
           + driver.getEmail()
           + "\" OR "
           + "`idNumber` = \""
           + driver.getIdNumber()
           + "\"";
   ResultSet resultSet = statement.executeQuery(query);
   while (resultSet.next()) {
     exists = true;
   }
   disconnect();
   return exists;
 }
Пример #3
0
 public int approveApplication() throws SQLException {
   connect();
   Statement statement = connection.createStatement();
   String query =
       "UPDATE `Users` SET `isActive` = \""
           + 1
           + "\" WHERE"
           + " `userID` = \""
           + driver.getUserID()
           + "\"";
   int result = statement.executeUpdate(query);
   disconnect();
   return result;
 }
Пример #4
0
 public int updateDriver(Driver driver) throws SQLException {
   connect();
   Statement statement = connection.createStatement();
   String query = null;
   int result = 0;
   if (driver.getTruck().getPlateNumber().equals("None")) {
     query =
         "UPDATE `Drivers` SET `plateNumber` = NULL"
             + " WHERE `driverID` = \""
             + driver.getUserID()
             + "\"";
   } else {
     query =
         "UPDATE `Drivers` SET `plateNumber` = \""
             + driver.getTruck().getPlateNumber()
             + "\""
             + " WHERE `driverID` = \""
             + driver.getUserID()
             + "\"";
   }
   result += statement.executeUpdate(query);
   disconnect();
   return result;
 }