Пример #1
0
 @Override
 public boolean insert(CheckOut co) {
   try {
     this.pStat = this.conn.prepareStatement(INSERT);
     this.pStat.setString(1, co.getId());
     this.pStat.setDate(2, new java.sql.Date(co.getDate().getTime()));
     this.pStat.setString(3, co.getMemo());
     this.pStat.setString(4, co.getRegistrasi().getIdRegistrasi());
     this.pStat.setString(5, co.getUser().getIdUser());
     if (this.pStat.executeUpdate() == 1) return true;
   } catch (SQLException e) {
     System.out.println("terjadi error pada saat insert user");
     System.out.println(e.getMessage());
     return false;
   }
   return false;
 }
Пример #2
0
 @Override
 public List<CheckOut> selectAll() {
   try {
     this.stat = this.conn.createStatement();
     this.rs = this.stat.executeQuery(SELECT_ALL);
     this.list = new ArrayList<CheckOut>();
     while (this.rs.next()) {
       CheckOut co = new CheckOut();
       co.setId(this.rs.getString("id_checkout"));
       co.setMemo(this.rs.getString("memo_checkout"));
       co.setDate(this.rs.getDate("date_checkout"));
       co.getRegistrasi().setIdRegistrasi(this.rs.getString("id_reg"));
       co.getUser().setIdUser(this.rs.getString("id_user"));
       this.list.add(co);
     }
   } catch (SQLException e) {
     System.out.println("terjadi error pada saat mengambil semua data check out");
     System.out.println(e.getMessage());
   }
   return this.list;
 }