pagebusiness.java

来自「一个简易的网上书店(jsp+sqlservler+struts)。」· Java 代码 · 共 54 行

JAVA
54
字号
package com.webshop.page;
import java.sql.*;
import java.util.*;

/**
 * @author hellking
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
/**
 *抽象了分页显示的业务逻辑
 */
public abstract class PageBusiness 
{
	public java.util.Vector v;//要显示的信息。
	/**
	 *获得所有记录的数量
	 */
	public abstract int getAvailableCount(String conditions)throws Exception;
	/**
	 *返回要显示的信息
	 */
	public 	java.util.Vector getResult()throws Exception
	{
		return v;
	}
	/**
	 *一个帮助方法,用于获得指定的表的记录数量
	 */
	protected final int getAvailableCountHelper(Connection conn ,String tableName,String conditions)throws Exception
	{

		int ret=0;
		Statement stmt=conn.createStatement();
		String strSql="select count(*) as counters from "+tableName +" where "+conditions;
		ResultSet rset=stmt.executeQuery(strSql);
		while(rset.next())
		{
			ret=rset.getInt(1);
		}

		return ret;	
	}
	/**
	 *执行数据库操作,返回包含了指定页面信息的PageBean
	 */
	public abstract PageBean listData(String page,String conditions)throws Exception;	
		
}

⌨️ 快捷键说明

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