コード例 #1
0
ファイル: DriversFacade.java プロジェクト: shemistone/ncgms
 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
ファイル: DriversFacade.java プロジェクト: shemistone/ncgms
 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;
 }