예제 #1
0
파일: CourseDAO.java 프로젝트: leontian/db
  public Course insert(int cid, String title, Dept dept) {
    try {
      // make sure that the cid is currently unused
      if (find(cid) != null) return null;

      String cmd = "insert into COURSE(CId, Title, DeptId) " + "values(?, ?, ?, ?)";
      PreparedStatement pstmt = conn.prepareStatement(cmd);
      pstmt.setInt(1, cid);
      pstmt.setString(2, title);
      pstmt.setInt(3, dept.getId());
      pstmt.executeUpdate();
      return new Course(this, cid, title, dept);
    } catch (SQLException e) {
      dbm.cleanup();
      throw new RuntimeException("error inserting new course", e);
    }
  }
예제 #2
0
파일: Dept.java 프로젝트: jjk123/Test
 public boolean equals(Object obj) {
   if (obj instanceof Dept == false) return false;
   if (this == obj) return true;
   Dept other = (Dept) obj;
   return new EqualsBuilder().append(getDeptId(), other.getDeptId()).isEquals();
 }