📄 coursemanager.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -