use of Model.Courses in project Happourse_online_study_web by infiq2000.
the class TakeCourse method doGet.
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
int course_id = Integer.parseInt(request.getParameter("course_id"));
try {
Courses detailC = courseUtil.getCourseDetail(course_id);
request.setAttribute("course_detail", detailC);
String cate = insUtil.getCate(detailC.getCid());
request.setAttribute("cate", cate);
Instructor ins_info = insUtil.getIns_Info(detailC.getIns_id());
request.setAttribute("ins_info", ins_info);
request.setAttribute("course_id", course_id);
RequestDispatcher dispatcher = request.getRequestDispatcher("/takecourse.jsp");
dispatcher.forward(request, response);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of Model.Courses in project Happourse_online_study_web by infiq2000.
the class CourseUtil method checkSignedCourse.
public Courses checkSignedCourse(int course_id, int uid) throws SQLException {
Connection myConn = null;
ResultSet myRS = null;
myConn = dataSource.getConnection();
String sql = "SELECT * FROM happourse.user_course c WHERE uid=? AND course_id=?;";
PreparedStatement pstmt = myConn.prepareStatement(sql);
pstmt.setInt(1, uid);
pstmt.setInt(2, course_id);
myRS = pstmt.executeQuery();
Courses course;
if (myRS.next()) {
course = getCourseDetail(course_id);
myConn.close();
return course;
} else {
myConn.close();
return null;
}
}
use of Model.Courses in project Happourse_online_study_web by infiq2000.
the class CourseUtil method listCourse_Id.
public List<Courses> listCourse_Id(int uid) throws SQLException {
Connection myConn = null;
PreparedStatement myStmt = null;
ResultSet myRS = null;
myConn = dataSource.getConnection();
String sql = "SELECT * FROM Happourse.courses c, Happourse.instructor i WHERE c.ins_id = i.ins_id AND c.course_id IN ( SELECT course_id FROM Happourse.user_course WHERE uid = ?)";
myStmt = myConn.prepareStatement(sql);
myStmt.setInt(1, uid);
myRS = myStmt.executeQuery();
List<Courses> ls = new ArrayList<>();
while (myRS.next()) {
int courses_id = myRS.getInt("course_id");
String name = myRS.getString("name");
String skill = myRS.getString("skill");
int price = myRS.getInt("price");
String language = myRS.getString("language");
String description = myRS.getString("description");
double star_rate = myRS.getDouble("star_rate");
int ins_id = myRS.getInt("ins_id");
int cid = myRS.getInt("cid");
String ins_name = myRS.getString("ins_name");
String major = myRS.getString("major");
Courses course = new Courses(courses_id, name, skill, price, language, star_rate, description, ins_id, cid, ins_name, major);
ls.add(course);
}
myConn.close();
return ls;
}
use of Model.Courses in project Happourse_online_study_web by infiq2000.
the class UserUtil method getAll_Courses.
public List<Courses> getAll_Courses() throws SQLException {
Connection myConn = null;
PreparedStatement myStmt = null;
ResultSet myRS = null;
myConn = dataSource.getConnection();
String sql = "select * from courses ";
myStmt = myConn.prepareStatement(sql);
myRS = myStmt.executeQuery();
List<Courses> courses = new ArrayList<>();
while (myRS.next()) {
int courses_id = myRS.getInt("course_id");
String name = myRS.getString("name");
String skill = myRS.getString("skill");
int price = myRS.getInt("price");
String language = myRS.getString("language");
String description = myRS.getString("description");
double star_rate = myRS.getDouble("star_rate");
int ins_id = myRS.getInt("ins_id");
int cid = myRS.getInt("cid");
courses.add(new Courses(courses_id, name, skill, price, language, star_rate, description, ins_id, cid));
}
return courses;
}
Aggregations