根据Id找出公司所有职位

<%
		out.println("<br/>");
 		int count=0;
 		Connection connl = null;
		PreparedStatement psl = null;
		ResultSet rsl = null;
		try {
				connl=DBClassLocal.getConnection();
				String sql = "select count(*) from local_recruitfirm t";
				psl = connl.prepareStatement(sql);
				psl.executeUpdate();
				rsl=psl.executeQuery();
				while (rsl.next()) {
					count=rsl.getInt(1);
				}
			}catch(Exception e){
				e.printStackTrace();
			}finally{
				if(rsl!=null){
					rsl.close();
				}
				if(psl!=null){
					rsl.close();
				}
				if(connl!=null){
					connl.close();
				}
			}

 %>

<%
	Connection connls = null;
		PreparedStatement psls = null;
		ResultSet rsls = null;
		int pagesize=5;
		int pagenum=1;
		if(request.getParameter("pn")!=null){
			pagenum=Integer.parseInt(request.getParameter("pn"));
		}
		try {
				connls=DBClassLocal.getConnection();
				String sql = "select * from (select t.*, rownum rn from (select * from local_recruitfirm  order by createtime desc)t where rownum<=? )  where rn>?";
				psls = connls.prepareStatement(sql);
				psls.setInt(1,pagesize*pagenum);
				psls.setInt(2,pagesize*(pagenum-1));
		//		psls.execute();
				psls.executeUpdate();
				rsls=psls.executeQuery();
				while (rsls.next()) {
					out.println("<a href='zhiwei?zid="+rsls.getInt("fid")+"'>"+rsls.getString("firmposition")+"</a>");
					out.println("<br/>");
				}
			}catch(Exception e){
				e.printStackTrace();
			}finally{
				if(rsls!=null){
					rsls.close();
				}
				if(psls!=null){
					psls.close();
				}
				if(connls!=null){
					connls.close();
				}
			}
		
 		out.println(Pager.getPagerSimple(count, pagesize, pagenum, "company.jsp")); 

 %>


你可能感兴趣的:(sql,jsp)