jsp对dao层的工具类

来源:互联网 发布:python爬虫源码 编辑:程序博客网 时间:2024/06/05 16:33
public class EmpDao extends DbOperation{public ArrayList selectAll(){ArrayList al=new ArrayList();//使用JDBC连接数据库 查询数据try {//连接数据库getConn();//执行查询extQuery("select * from emp");//处理查询结果while(rs.next()){Emp e=new Emp();e.setComm(rs.getInt("comm"));e.setDeptno(rs.getInt("deptno"));e.setEmpno( rs.getInt("empno"));e.setEname( rs.getString("ename"));e.setHiredate( rs.getDate("hiredate"));e.setJob( rs.getString("job"));e.setMgr( rs.getInt("mgr"));e.setSal( rs.getInt("sal"));al.add(e);}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}return al;}public void insert(Emp e){//连接数据库getConn();//执行sql语句 使用预编译可以防止sql注入extUpdate("delete from emp where empno=?",1,2);//关闭连接closeAll();}}

原创粉丝点击