日期:2014-05-16 浏览次数:20706 次
定义:pageStart 起始页,pageEnd 终止页,pageSize页面容量
oracle分页:
select * from ( select mytable.*,rownum?num from (实际传的SQL) where?rownum<=pageEnd) where num>=pageStart
sqlServer分页:
???????????select * from ( select?top?页面容量 from( select?top? 页面容量*当前页码 * from 表 where 条件 order by 字段A) as temptable1 order by
字段A desc) as temptable2 order by 字段A
Mysql分页:
?????????select * from mytable where 条件?limit?当前页码*页面容量-1?to?页面容量
Java分页接口和实现类:
?
package com.qg.demo.util;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
public class OracleUtil {
?private String dataSourceName;
?private DataSource ds;
?public OracleUtil(String dataSourceName){
??this.dataSourceName = dataSourceName;
?}
?public OracleUtil(){
??
?}
?public void setDataSourceName(String dataSourceName){