📄 coursebean.java
字号:
sql += " order by a.course_id";
DBAccess dba = new DBAccess();
try {
dba.getConnection();
ArrayList arrayList = new ArrayList();
ResultSet rs = null;
rs = dba.query(sql);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
arrayList.add(courseBean);
}
return arrayList;
}
} catch (SQLException ex) {
return null;
} finally {
dba.closeConnection();
}
return null;
}
public Hashtable queryCourseScheme(String classId, String studentId,
String term) {
String sql = "select a.course_id,a.course_name,a.type,b.name teachername,b.id teacher_id,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,a.description from course_info a,teach_info b,selective_course_scheme c where a.type!='A' and a.teach_id=b.id and a.course_id=c.course_id and a.term=" +
term + " and c.stu_id=" +
studentId;
String sql2 = "select a.course_id,a.course_name,a.type,b.name teachername,a.teach_id teacher_id,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,a.description from course_info a,teach_info b,required_course_scheme c where a.type='A' and a.teach_id=b.id and a.course_id=c.course_id and a.term=" +
term + " and c.class_id=" +
classId;
DBAccess dba = new DBAccess();
try {
dba.getConnection();
Hashtable courseHTable = new Hashtable();
ResultSet rs = null;
rs = dba.query(sql);
String key = null;
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
key = rs.getString("week").trim() + "-" +
rs.getString("period").trim();
courseHTable.put(key, courseBean);
}
}
rs = null;
rs = dba.query(sql2);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
key = rs.getString("week").trim() + "-" +
rs.getString("period").trim();
courseHTable.put(key, courseBean);
}
return courseHTable;
}
} catch (SQLException ex) {
return null;
} finally {
dba.closeConnection();
}
return null;
}
public Hashtable querySelectiveCourses(String studentId, String term) {
String sql = "select a.course_id,a.course_name,a.type,b.name teachername,b.id teacher_id,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,a.description from course_info a,teach_info b,required_course_scheme c where a.teach_id=b.id and a.course_id=c.course_id and a.term=" +
term + " and c.stu_id=" + studentId;
DBAccess dba = new DBAccess();
try {
dba.getConnection();
Hashtable courseHTable = new Hashtable();
ResultSet rs = null;
String key = null;
rs = dba.query(sql);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
key = rs.getString("week").trim() + "-" +
rs.getString("period").trim();
courseHTable.put(key, courseBean);
}
return courseHTable;
}
} catch (SQLException ex) {
return null;
} finally {
dba.closeConnection();
}
return null;
}
public ArrayList queryCanChooseCourse(String term, String week,
String period) {
String sql = "select a.course_id,a.course_name,a.type,b.name teachername,b.id teacher_id,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,a.description from course_info a,teach_info b where a.teach_id=b.id";
if(term != null && term.length() > 0){
sql += " and a.term=" + term;
}
if(week != null && week.length() > 0){
sql += " and a.week=" + week;
}
if(period != null && week.length() > 0){
sql += " and a.period=" + period;
}
sql += " and a.type!='A'";
sql += " order by a.course_id";
DBAccess dba = new DBAccess();
try {
dba.getConnection();
ArrayList arrayList = new ArrayList();
ResultSet rs = null;
rs = dba.query(sql);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
arrayList.add(courseBean);
}
return arrayList;
}
} catch (SQLException ex) {
return null;
} finally {
dba.closeConnection();
}
return null;
}
public ArrayList queryChoosedCourse(String term ,String studentId) {//查询某人某学期已经选修的课程,推选课程时使用此方法
String sql = "select a.course_id,a.course_name,a.type,b.id teacher_id,b.name teachername,a.term,a.week,a.period,a.begintime,a.endtime,a.classroom,a.description from course_info a,teach_info b,selective_course_scheme c where a.teach_id=b.id and c.course_id=a.course_id";
sql += " and a.term=" + term;
sql += " and c.stu_id="+studentId;
sql += " order by a.course_id";
DBAccess dba = new DBAccess();
try {
dba.getConnection();
ArrayList arrayList = new ArrayList();
ResultSet rs = null;
rs = dba.query(sql);
if (rs != null) {
while (rs.next()) {
CourseBean courseBean = new CourseBean();
courseBean.setBeginTime(rs.getInt("begintime"));
courseBean.setClassRoom(rs.getString("classroom"));
courseBean.setCourseId(rs.getString("course_id"));
courseBean.setCourseName(rs.getString("course_name"));
courseBean.setCourseType(rs.getString("type"));
courseBean.setDescription(rs.getString("description"));
courseBean.setEndTime(rs.getInt("endtime"));
courseBean.setPeriod(rs.getInt("period"));
courseBean.setTeacherName(rs.getString("teachername"));
courseBean.setTeacherId(rs.getString("teacher_id"));
courseBean.setTerm(rs.getInt("term"));
courseBean.setWeek(rs.getInt("week"));
arrayList.add(courseBean);
}
return arrayList;
}
} catch (SQLException ex) {
System.out.println("产生异常:in CourseBean.queryChoosedCourse()");///////////////////////
ex.printStackTrace();
return null;
} finally {
dba.closeConnection();
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -