Exemplo n.º 1
0
 public Pelamar getPelamarByUsername(String username) {
   super.openConnection();
   String query = String.format("SELECT * FROM %s where username='******' ", TABLE_NAME, username);
   try {
     ResultSet res = super.getStatement().executeQuery(query);
     // selama masih ada baris yang bisa dibaca
     res.next();
     Pelamar a =
         new Pelamar(
             res.getInt("id"),
             res.getInt("id_lowongan"),
             res.getString("username"),
             res.getInt("id_cv"),
             res.getString("jenis"),
             res.getString("status"),
             res.getString("created_at"),
             res.getString("updated_at"));
     return a;
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
   return null;
 }
Exemplo n.º 2
0
 public ArrayList<Pelamar> selectPelamarJenisStatus(int id_lowongan, String jenis, String status) {
   super.openConnection();
   String query =
       String.format(
           "SELECT * FROM %s where id_lowongan ='%s' AND jenis='%s' AND status='%s' ",
           TABLE_NAME, id_lowongan, jenis, status);
   ArrayList<Pelamar> result = new ArrayList<Pelamar>();
   try {
     ResultSet res = super.getStatement().executeQuery(query);
     // selama masih ada baris yang bisa dibaca
     while (res.next()) {
       Pelamar a =
           new Pelamar(
               res.getInt("id"),
               res.getInt("id_lowongan"),
               res.getString("username"),
               res.getInt("id_cv"),
               res.getString("jenis"),
               res.getString("status"),
               res.getString("created_at"),
               res.getString("updated_at"));
       result.add(a);
     }
     return result;
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
   return null;
 }
Exemplo n.º 3
0
 public void updateStatusLamaran(int id, boolean accepted) {
   String status = accepted ? "accept" : "reject";
   String query =
       String.format("UPDATE %s SET status='%s' WHERE id=%s", this.TABLE_NAME, status, id);
   super.openConnection();
   try {
     super.getStatement().executeUpdate(query);
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
 }
Exemplo n.º 4
0
 public void cregPelamar(int id_lowongan, String username) {
   super.openConnection();
   String query =
       String.format(
           "INSERT INTO %s (id_lowongan, username, jenis) VALUES ('%s','%s','%s')",
           TABLE_NAME, id_lowongan, username, "close");
   try {
     super.getStatement().executeUpdate(query);
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
 }
Exemplo n.º 5
0
 /**
  * menambahkan user baru
  *
  * @param username
  * @param password
  */
 public void insertUser(String username, String password) {
   super.openConnection();
   String query =
       String.format(
           "INSERT INTO %s(username, password) VALUES ('%s', '%s')",
           TABLE_NAME, username, password);
   openConnection();
   try {
     super.getStatement().executeUpdate(query);
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
 }
Exemplo n.º 6
0
 /**
  * Untuk ambil user dengan id tertentu
  *
  * @param username
  * @return
  */
 public User select(String username) {
   super.openConnection();
   String query = "SELECT * FROM " + TABLE_NAME + " WHERE username='******'";
   User a = null;
   try {
     ResultSet res = super.getStatement().executeQuery(query);
     while (res.next()) {
       a = new User(res.getString("username"), res.getString("password"));
     }
     return a;
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
   return a;
 }
Exemplo n.º 7
0
 /**
  * untuk edit user password
  *
  * @param username
  * @param password
  */
 public void editUser(String username, String password) {
   super.openConnection();
   String query =
       "UPDATE "
           + TABLE_NAME
           + " SET password='******' WHERE username='******'";
   openConnection();
   try {
     super.getStatement().executeUpdate(query);
   } catch (SQLException ex) {
     Logger.getLogger(Model.class.getName()).log(Level.SEVERE, null, ex);
   } finally {
     closeConnection();
   }
 }