Oracle和DB2数据库分页的StringUtil工具

public final class PageSqlUtil {

  public static String getOraclePageSqlString(String sql) {
      String postsql = "SELECT * FROM (SELECT A.*,ROWNUM ROW_NUM FROM ("+sql+") A) B WHERE ";
		int pageCount = getTopEntryNum();
     postsql += " B.ROW_NUM BETWEEN "+((pageNum - 1) * pageCount ) +" AND "+(pageCount * pageNum );
     return postsql;  }

public static PageStringUtilBean getDB2PageString(String sql, int pageNum , int pageCount){
		PageStringUtilBean bean = new PageStringUtilBean();
		
		if(pageCount == 0)
			pageCount = getTopEntryNum();
		String postsql = "SELECT * FROM ("+
						sql + 
						") AS ENTRY_TEMP WHERE ROW_NEXT BETWEEN ? and ?";
		
		bean.setSql(postsql);
		bean.setBegin((pageNum - 1) * pageCount);
		bean.setEnd(pageCount * pageNum);
		return bean;
	}

}

 

你可能感兴趣的:(oracle,sql,bean,db2)