Ejemplo n.º 1
0
  public boolean addMarketingOfficer(MarketingOfficer marketingOfficer)
      throws SQLException, ClassNotFoundException {
    Connection connection = DataBaseConnection.getConnection();
    Statement createStatement = connection.createStatement();
    String sql =
        "INSERT INTO MARKETINGOFFICER (marketingofficerid,name,nic,address,telno) "
            + "VALUES ('"
            + marketingOfficer.getMarketingOfficerId()
            + "','"
            + marketingOfficer.getName()
            + "','"
            + marketingOfficer.getNic()
            + "','"
            + marketingOfficer.getAddress()
            + "','"
            + marketingOfficer.getTelNo()
            + "')";
    int res = createStatement.executeUpdate(sql);

    if (res > 0) {
      return true;
    } else {
      return false;
    }
  }
Ejemplo n.º 2
0
 public MarketingOfficer searchMarketingOfficer(String marketingOfficer)
     throws SQLException, ClassNotFoundException {
   Connection connection = DataBaseConnection.getConnection();
   Statement createStatement = connection.createStatement();
   String sql =
       "select * from marketingofficer where marketingofficerid='" + marketingOfficer + "'";
   System.out.println(sql);
   ResultSet executeQuery = createStatement.executeQuery(sql);
   MarketingOfficer mo = new MarketingOfficer();
   while (executeQuery.next()) {
     mo.setName(executeQuery.getString("name"));
     mo.setNic(executeQuery.getString("nic"));
     mo.setAddress(executeQuery.getString("address"));
     mo.setTelNo(executeQuery.getString("telNo"));
   }
   return mo;
 }