coursemanager.java
来自「功能还没做全的选课系统」· Java 代码 · 共 80 行
JAVA
80 行
package com.xuanke.student.control;
import java.util.List;
import com.xuanke.student.model.CoursetBean;
import com.xuanke.student.model.CourseDAO;
import com.xuanke.utils.DBConnectionManager;
import com.xuanke.utils.MyJDBCException;
public class CourseManager {
private static CourseManager instance=null;
private CourseDAO dao=null;
/*
* 下列代码的基本意图是,保证StudentManager类仅有一个实例对象
* 有利于进行内存控制
* 还有利于继承StudentManager类,并在getInstance方法中返回其子类
* 如有如下类:
* public class NewStudentManager extends StudentManager{
* ......
* }
* 如果希望StudentManager的getInstance方法返回NewStudentManager的实例
* 则只需要把getInstance方法修改为
* public static StudentManager getInstance(){
if(instance==null)
instance=new NewStudentManager();
return instance;
}
*/
private CourseManager(){
}
public static CourseManager getInstance(){
if(instance==null)
instance=new CourseManager();
return instance;
}
public List findAll() throws BusinessException{
// TODO 自动生成方法存根
try {
dao=new CourseDAO(DBConnectionManager.getConnection());
return dao.findAll();
} catch (MyJDBCException e) {
throw new BusinessException(e.getMessage());
}
}
public List findPersonalAll() throws BusinessException{
// TODO 自动生成方法存根
try {
dao=new CourseDAO(DBConnectionManager.getConnection());
return dao.findPersonalAll();
} catch (MyJDBCException e) {
throw new BusinessException(e.getMessage());
}
}
public void delete(String id) throws BusinessException{
// TODO 自动生成方法存根
try {
dao=new CourseDAO(DBConnectionManager.getConnection());
dao.delete(id);
} catch (MyJDBCException e) {
throw new BusinessException(e.getMessage());
}
}
public void add(String id) throws BusinessException{
try {
dao=new CourseDAO(DBConnectionManager.getConnection());
dao.add(id);
} catch (MyJDBCException e) {
throw new BusinessException(e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?