public Course CourseDetail(long idcourse) throws SQLException {

		String query = "";
		String query1 = "";
		String query2 = "";
		String query3 = "";

		Course courseInfo = new Course();

		List<Instructor> instructorInfo = new ArrayList<Instructor>();
		int index = 0;
		long[] personid = null;
		try {

			query = "select * from course where idcourse= ?";
			ps = con.prepareStatement(query);
			ps.setLong(1, idcourse);

			rs = ps.executeQuery();

			if (rs.next()) {
				courseInfo = new Course();
				courseInfo.setCourseId(rs.getInt(1));
				courseInfo.setName(rs.getString(2));
				courseInfo.setSection(rs.getString(3));
				courseInfo.setHours(rs.getString(4));
				courseInfo.setLocation(rs.getString(5));

			} else {
				System.out.println("Course with id = " + idcourse
						+ " does not exist.");
				return null;
			}

			query1 = "select idperson from personcoursemap where idcourse = ?";
			query2 = "select fname, lname from person where idperson = ? and persontype='I'";
			query3 = "select * from instructor where idperson= ?";

			// search for the all related person to course
			ps1 = con.prepareStatement(query1);
			ps1.setLong(1, idcourse);
			rs1 = ps1.executeQuery();

			// get the count of no of persons related to course
			int count = 0;
			while (rs1.next()) {
				count++;
			}
			personid = new long[count];
			rs1.beforeFirst();// reset pointer on top of the list

			while (rs1.next()) {
				personid[index] = rs1.getInt(1);
				index++;
			}

			for (int i = 0; i < index - 1; i++) {
				Instructor tempInstructor = new Instructor();
				// get instructor name info
				ps2 = con.prepareStatement(query2);
				ps2.setLong(1, personid[i]);
				rs2 = ps2.executeQuery();

				if (rs2.next()) {
					tempInstructor.setFirstName(rs2.getString(1));
					tempInstructor.setLastName(rs2.getString(2));

					// get instructor official detail
					ps3 = con.prepareStatement(query3);
					ps3.setLong(1, personid[i]);
					rs3 = ps3.executeQuery();
					if (rs3.next()) {
						tempInstructor.setPersonId(rs3.getLong(1));
						tempInstructor.setDepartment(rs3.getString(2));
						tempInstructor.setOffficeHr(rs3.getString(3));
						tempInstructor.setLocation(rs3.getString(4));
					}
				}

				instructorInfo.add(tempInstructor);

			}

			courseInfo.setCourseTeachers(instructorInfo
					.toArray(new Instructor[instructorInfo.size()]));
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
     	      
                ps.close();
                ps1.close();
                ps2.close();
                ps3.close();
                // connectionPool.free(con);
            } catch (SQLException e) {
               // TODO Auto-generated catch block
                 e.printStackTrace();
              } 
		}
		return courseInfo;
	}