?? coursedao.java
字號(hào):
package com.xuanke.student.model;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import com.xuanke.utils.JDBCBase;
import com.xuanke.utils.MyJDBCException;
public class CourseDAO extends JDBCBase {
public CourseDAO(Connection conn) {
super(conn);
}
public void add(String id) throws MyJDBCException {
String sql = "insert into PersonCourse(CourseID) values("+id+ ")";
this.execute(sql);
}
public void delete(String id) throws MyJDBCException {
String sql = "delete from PersonCourse where CourseID="+id+ "";
System.out.println(sql);
this.execute(sql);
}
public void modify(CoursetBean stu) throws MyJDBCException {
//this.execute(sql);
}
public List findAll() throws MyJDBCException {
String sql = "select * from Course";
List result = null;
ResultSet rs = this.qry(sql);
result = new ArrayList();
try {
while (rs.next()) {
// 數(shù)據(jù)庫(kù)中每行轉(zhuǎn)換為一個(gè)StudentBean對(duì)象,并把這些對(duì)象裝入一個(gè)List中后返回
CoursetBean stu = new CoursetBean();
stu.setId(rs.getString(1));
stu.setName(rs.getString(2));
stu.setDate(rs.getString(3));
stu.setXuefen(rs.getInt(4));
result.add(stu);
}
rs.getStatement().close();
} catch (SQLException ex) {
}
return result;
}
public List findPersonalAll() throws MyJDBCException {
String sql = "select Course.CourseID,Course.CourseName,Course.CourseTime,Course.CourseXuefen from Course,PersonCourse where Course.CourseID=PersonCourse.CourseID";
//String sql = "select * from Course";
List result = null;
ResultSet rs = this.qry(sql);
result = new ArrayList();
try {
while (rs.next()) {
// 數(shù)據(jù)庫(kù)中每行轉(zhuǎn)換為一個(gè)StudentBean對(duì)象,并把這些對(duì)象裝入一個(gè)List中后返回
CoursetBean stu = new CoursetBean();
stu.setId(rs.getString(1));
stu.setName(rs.getString(2));
stu.setDate(rs.getString(3));
stu.setXuefen(rs.getInt(4));
result.add(stu);
}
rs.getStatement().close();
} catch (SQLException ex) {
}
return result;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -