⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coursedao.java

📁 功能还没做全的选课系统
💻 JAVA
字号:
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()) {
				// 数据库中每行转换为一个StudentBean对象,并把这些对象装入一个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()) {
				// 数据库中每行转换为一个StudentBean对象,并把这些对象装入一个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;

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -