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

📄 studentservice.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 JAVA
字号:
/**
 * 
 */
package edu.yinhe.mis.services;

import java.sql.SQLException;
import java.util.ArrayList;

import edu.yinhe.mis.dto.DictionaryDTO;
import edu.yinhe.mis.dto.StudentDTO;
import edu.yinhe.mis.dto.TeacherDTO;
import edu.yinhe.mis.model.DAOFactory;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.model.IBaseDAO;
import edu.yinhe.system.services.Service;

/**
 * @author 吴朋
 *
 */
public class StudentService extends Service{
    IBaseDAO studao=null;
    IBaseDAO dicdao=null;
    IBaseDAO teadao=null;
	public Object alllist() throws AppException {
		// TODO Auto-generated method stub
		return null;
	}
	/**
	 * 根据ID号查询信息 
	 * @author 吴朋
	 * @param obj 传入StudentDTO对象
	 * @return 返回一个objs数组
	 * @exception SQLException
	 * creation date :04-30-2008
	 */
	public Object alllist(Object obj) throws AppException {
		studao = DAOFactory.getStudentDAO(conn);
		StudentDTO sdto =null;;
		Object[] objs=null;
		try {
			sdto=(StudentDTO) obj;
			objs= (Object[]) studao.findAll(sdto);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			sdto=null;
			studao=null;
		}
		return objs;
	}

	public Object create(Object obj) throws AppException {
	studao=DAOFactory.getStudentDAO(conn);
	StudentDTO sdto=null;
	
	boolean flag=false;
	try {
		sdto=(StudentDTO) obj;
		flag=(Boolean) studao.insert(sdto);
	} catch (SQLException e) {
		try {
			conn.rollback();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		e.printStackTrace();
	}finally{
		this.closeConnection();
		studao=null;
		sdto=null;
	}
		return flag;
	}

	public Object findAll() throws AppException {
		studao = DAOFactory.getStudentDAO(conn);
		Object[] objs=null;
		try {
			objs= (Object[]) studao.findAll();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			studao=null;
		}
		return objs;
	}

	public Object findAll(Object obj) throws AppException {
		dicdao = DAOFactory.getDictionaryDAO(conn);
		Object[] objs=null;
		DictionaryDTO ddto=null;
		try {
			ddto=(DictionaryDTO) obj;
			objs= (Object[]) dicdao.findAll(ddto);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			dicdao=null;
		}
		return objs;
	}
	/**
	 * 根据ID号查询信息 
	 * @author 吴朋
	 * @param obj 传入StudentDTO对象
	 * @return 返回一个arraylist集合
	 * @exception SQLException
	 * creation date :04-30-2008
	 */
	public Object findById(Object obj) throws AppException {
		studao=DAOFactory.getStudentDAO(conn);
		ArrayList arraylist=null;
		StudentDTO sdto=null;
		try {
			sdto=(StudentDTO) obj;
			arraylist=(ArrayList) studao.findById(sdto);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			studao=null;
			sdto=null;
		}
		return arraylist;
	}

	public Object findByObject(Object arg0) throws AppException {
		// TODO Auto-generated method stub
		return null;
	}

	public int getcount() throws AppException {
		// TODO Auto-generated method stub
		return 0;
	}

	public int getcount(Object arg0) throws AppException {
		// TODO Auto-generated method stub
		return 0;
	}

	public Object list() throws AppException {
		studao = DAOFactory.getStudentDAO(conn);
		ArrayList arraylist=null;
		try {
			arraylist= (ArrayList) studao.find();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			studao=null;
		}
		return arraylist;
	}

	public Object list(Object arg0) throws AppException {
		// TODO Auto-generated method stub
		return null;
	}

	public Object load(Object obj) throws AppException {
		teadao = DAOFactory.getTeacherDAO(conn);
		Object[] objs=null;
		TeacherDTO tdto=null;
		try {
			tdto=(TeacherDTO) obj;
			objs= (Object[]) teadao.findAll(tdto);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			dicdao=null;
		}
		return objs;
	}
	/**
	 * 根据ID号修改学生信息 
	 * @author 吴朋
	 * @param obj 传入StudentDTO对象
	 * @return 返回一个boolean类型的值
	 * @exception SQLException
	 * creation date :04-30-2008
	 */
	public Object modify(Object obj) throws AppException {
		studao=DAOFactory.getStudentDAO(conn);
		boolean flag=false;
		StudentDTO sdto=null;
		try {
			sdto=(StudentDTO) obj;
			flag=(Boolean) studao.update(sdto);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			studao=null;
			sdto=null;
		}
		return flag;
	}
	/**
	 * 根据ID号删除学生信息 
	 * @author 吴朋
	 * @param obj 传入StudentDTO对象
	 * @return 返回一个boolean类型的值
	 * @exception SQLException
	 * creation date :04-30-2008
	 */
	public Object remove(Object obj) throws AppException {
		studao=DAOFactory.getStudentDAO(conn);
		boolean flag=false;
		try {
			flag=(Boolean) studao.delete(obj);
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			e.printStackTrace();
		}finally{
			this.closeConnection();
			studao=null;
		}
		return flag;
	}

}

⌨️ 快捷键说明

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