public List<EmpVO> getPageEmp(int empno) { conn = getConn(); String sql = "select * from" + "(select trunc((rownum-1)/12)+1 as page," + "lpad('¡¡',(level-1)*5,'¡¡')||DECODE(LEVEL,1,'','¦¦')||ename as ename," + "empno,hiredate,sal,deptno " + "from emp2 " + "start with ename='KING'connect by prior empno=mgr" + ")" + "where empno=?"; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, empno); rs = pstmt.executeQuery(); List<EmpVO> list = new ArrayList<>(); while (rs.next()) { EmpVO emp = new EmpVO(); emp.setEmpno(rs.getInt("EMPNO")); emp.setEname(rs.getString("ENAME")); emp.setHiredate(rs.getDate("HIREDATE")); emp.setSal(rs.getInt("SAL")); emp.setDeptno(rs.getInt("DEPTNO")); list.add(emp); } return list; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { closeAll(); } return null; }
public boolean bgetEmp(int empno, String ename) { conn = getConn(); String sql = "select * from emp2 where empno=? and ename =?"; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, empno); pstmt.setString(2, ename); rs = pstmt.executeQuery(); List<EmpVO> list = new ArrayList<>(); while (rs.next()) { EmpVO emp = new EmpVO(); emp.setEmpno(rs.getInt("EMPNO")); emp.setEname(rs.getString("ENAME")); emp.setHiredate(rs.getDate("HIREDATE")); emp.setSal(rs.getInt("SAL")); emp.setDeptno(rs.getInt("DEPTNO")); list.add(emp); } if (list.size() > 0) { return true; } else { return false; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { closeAll(); } return false; }
public List<EmpVO> getEmpList() { conn = getConn(); String sql = "SELECT * FROM emp2"; try { pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); List<EmpVO> list = new ArrayList<>(); while (rs.next()) { EmpVO emp = new EmpVO(); emp.setEmpno(rs.getInt("EMPNO")); emp.setEname(rs.getString("ENAME")); emp.setHiredate(rs.getDate("HIREDATE")); emp.setSal(rs.getInt("SAL")); emp.setDeptno(rs.getInt("DEPTNO")); list.add(emp); } return list; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { closeAll(); } return null; }
public EmpVO getEmp(int empno) { conn = getConn(); String sql = "select * from emp2 where empno=?"; try { pstmt = conn.prepareStatement(sql); pstmt.setInt(1, empno); rs = pstmt.executeQuery(); EmpVO emp = new EmpVO(); while (rs.next()) { emp.setEmpno(rs.getInt("EMPNO")); emp.setEname(rs.getString("ENAME")); emp.setHiredate(rs.getDate("HIREDATE")); emp.setSal(rs.getInt("SAL")); emp.setDeptno(rs.getInt("DEPTNO")); } return emp; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { closeAll(); } return null; }