public ArrayList<Object> getAppointments(AdvisorUser user) { ArrayList<Object> appointments = new ArrayList<Object>(); try { Connection conn = this.connectDB(); PreparedStatement statement; String command = "SELECT advisor_settings.pname,advisor_settings.email,advising_date,advising_starttime,advising_endtime,appointment_type,id,appointments.description,studentid,appointments.STUDENTID FROM USER,APPOINTMENTS,ADVISOR_SETTINGS " + "WHERE USER.email=? AND user.userid=appointments.advisor_userid AND advisor_settings.userid=appointments.advisor_userid"; statement = conn.prepareStatement(command); statement.setString(1, user.getEmail()); ResultSet rs = statement.executeQuery(); while (rs.next()) { Appointment set = new Appointment(); set.setPname(rs.getString(1)); set.setAdvisorEmail(rs.getString(2)); set.setAdvisingDate(rs.getString(3)); set.setAdvisingStartTime(rs.getString(4)); set.setAdvisingEndTime(rs.getString(5)); set.setAppointmentType(rs.getString(6)); set.setAppointmentId(rs.getInt(7)); set.setDescription(rs.getString(8)); set.setStudentid(rs.getString(9)); set.setStudentEmail(rs.getString(10)); appointments.add(set); } conn.close(); } catch (Exception e) { System.out.printf(e.toString()); } return appointments; }
public String addAppointmentType(AdvisorUser user, AppointmentType at) { String msg = null; SQLCmd cmd = new GetUserID(user.getEmail()); cmd.execute(); cmd = new AddAppointmentType(at, (int) cmd.getResult().get(0)); cmd.execute(); return (String) cmd.getResult().get(0); }