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); } }