public Course find(int cid) { try { String qry = "select Title, DeptId from COURSE where CId = ?"; PreparedStatement pstmt = conn.prepareStatement(qry); pstmt.setInt(1, cid); ResultSet rs = pstmt.executeQuery(); // return null if course doesn't exist if (!rs.next()) return null; String title = rs.getString("Title"); int deptid = rs.getInt("DeptId"); rs.close(); Dept dept = dbm.findDept(deptid); return new Course(this, cid, title, dept); } catch (SQLException e) { dbm.cleanup(); throw new RuntimeException("error finding course", e); } }