⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagemanage.java

📁 本方案是在与***信息技术(北京)有限公司相关人员协商并分析了北京****投资有限公司综合信息管理系统(以下简称“**管理系统”)相关资料之后提交的网络安全解决方案。 本方案描述***管理系统的网络
💻 JAVA
字号:
package com.test.dao.userpage;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;


public abstract class PageManage implements IPage {
	public static int USERBEAN = 1;
	
	protected int rowsInPage = 10;//每页显示多少行
	protected int rowsCount = -1;//总行数
	protected int currPage = -1;//当前页码
	protected int pageCount = -1;//总页数
	protected String tableName ;
	protected List data;

	/**
	 * 使用默认参数构造一个分页管理器
	 */
	public PageManage(){
	}
	
	/**
	 * 用指定参数构造一个分页管理器
	 * @param type	对什么类型的Bean进行分页,此类有已经定义好的参数
	 * @param rowsInPage	每页显示行数,如果小于1,则使用默认参数构造
	 * @return	返回一个构造好的分页管理器对象
	 */
	public static PageManage newInstance(int type,int rowsInPage) {
		PageManage pm = null;
		if(type == USERBEAN){
			pm = new UserBeanPageManage(rowsInPage);
		}
		return pm;
	}
	
	/**
	 * 返回当前页所包含的所有数据
	 * @param conn	活动的数据库连接,方法执行之后会调用conn的close()方法;
	 * @param tableName	要查询的表名
	 * @param currPage 要查询的页码
	 * @return	返回该页码所包含的数据
	 */
	public abstract IPage queryByPageIndex(Connection conn,int currPage);
	
	//设置总行数
	protected void setRowsCount(Statement stat) throws SQLException{
		try {
			ResultSet rs = stat.executeQuery("select count(*) from "+tableName);
			if(rs.next()){
				this.rowsCount = rs.getInt(1);
			}
			rs.close();			
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		}
	}
	
	//设置总页数
	protected void setPageCount(){
		this.pageCount = this.rowsCount/this.rowsInPage;
		if((this.rowsCount%this.rowsInPage)>0){
			this.pageCount++;
		}
	}
	
	public List getData(){
		return this.data;
	}

	public int getRowsInPage() {
		return rowsInPage;
	}

	public void setRowsInPage(int rowsInPage) {
		this.rowsInPage = rowsInPage;
	}

	public int getRowsCount() {
		return rowsCount;
	}

	public int getCurrPage() {
		return currPage;
	}

	public int getPageCount() {
		return pageCount;
	}
	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -