Beispiel #1
0
 public void editLopMonHocFull(LopMonHocEntity lop) throws SQLException {
   PreparedStatement stmt = null;
   Connection conn = null;
   SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
   try {
     String SQL =
         "update LOPMONHOC set MaGioHoc = ?, MaPhong = ?, NgayBatDauHoc = ?, NgayNghiDKBatDau = ?, NgayNghiDKKetThuc = ?, NgayHoc = ?, GiangVien = ?, NgayThiDuKien = ? WHERE IdLopMonHoc = ?";
     conn = DBPool.getConnection();
     stmt = conn.prepareStatement(SQL);
     stmt.setString(1, lop.getMaGioHoc());
     //            stmt.setString(2, format.format(sv.getNgaySinh()));
     stmt.setString(2, lop.getMaPhong());
     stmt.setString(3, format.format(lop.getNgayBatDauHoc()));
     stmt.setString(4, format.format(lop.getNgayNghiDKBatDau()));
     stmt.setString(5, format.format(lop.getNgayNghiDKKetThuc()));
     stmt.setString(6, lop.getNgayHoc());
     stmt.setString(7, lop.getGiangVien());
     stmt.setString(8, format.format(lop.getNgayThiDuKien()));
     stmt.setInt(9, lop.getIdLopMonHoc());
     stmt.executeUpdate();
   } finally {
     try {
       stmt.close();
       conn.close();
     } catch (SQLException ex) {
       throw ex;
     }
   }
 }
Beispiel #2
0
  public void deleteLopMonHoc(ArrayList<LopMonHocEntity> arr) throws SQLException, Exception {
    PreparedStatement stmt = null;
    Connection conn = null;
    try {
      conn = DBPool.getConnection();
      conn.setAutoCommit(false); // tao transaction
      for (LopMonHocEntity lopHoc : arr) {
        String SQL = "delete LOPMONHOC  where idLopMonHoc = ? ";
        stmt = conn.prepareStatement(SQL);
        stmt.setInt(1, lopHoc.getIdLopMonHoc());
        stmt.executeUpdate();
      }
      conn.commit();

    } catch (Exception ex) {
      conn.rollback();
      conn.setAutoCommit(true);
      throw new Exception(ex.getMessage());

    } finally {

      DBPool.releaseConnection(conn, stmt);
    }
  }