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

📄 honorslist.java

📁 是一个JSP与数据库应用系统
💻 JAVA
字号:
package until;

import java.sql.*;
import java.util.Vector;
import database.conn;
import until.honor;

public class honorSlist
{
	private int pagesize;
	private int pageno=1;
	private int Total = 0;
	private int TPages = 0;
	private int n = 1;       //此变量是设定分页时,
	private int pagers = 5; //此变量是设定分页时,页码的个数
	private String keyword;
	
	private Vector list;
	
	conn cn = new conn();
	
	public honorSlist()
	{
		pagesize = 1;
		keyword = "";
	}
	
	public void setKeyword(String keyword)
	{
		try
		{
			this.keyword = new String(keyword.getBytes("ISO8859_1"),"gb2312");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
	}
	
	public void setPagesize(int pagesize)
	{
		this.pagesize = pagesize;
	}
	
	
	public void setPageno(int pageno)
	{
	    this.pageno = pageno;
		
	}
	
	public int getTotal()
	{
		return Total;
	}
	public int getTPages()
	{
		return TPages;
	}
	
	public Vector getList()
	{
		return list;
	}
	
	public void Total()
	{
		try
		{
			    String strsql = "";
			    if((keyword==null)||(keyword.equals("")))
			    {
			    	strsql = "select Count(*) AS total from C_Honor";
			    }
			    else
			    {
			    	strsql = "select Count(*) AS total from C_Honor where title like '%"+keyword+"%'";
			    }
			    
				ResultSet rs = cn.executeQuery(strsql);
				if (rs.next())
				{
					 Total = rs.getInt(1);     
		             // 设置当前页数和总页数
		             TPages = (int)Math.ceil((double)Total/pagesize); 
				}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
	}
	
	public boolean pagelist()
	{
		boolean flag = false;
		try
		{
			String strsql = "";
			if((keyword==null)||(keyword.equals("")))
			{
				strsql="select top "+pagesize+" * from C_Honor where id not in(select top "+pagesize*(pageno-1)+" id from C_Honor order by id desc) order by id desc";
			}
			else
			{
				strsql="select top "+pagesize+" * from C_Honor where id not in(select top "+pagesize*(pageno-1)+" id from C_Honor where title like '%"+keyword+"%' order by id desc) and title like '%"+keyword+"%' order by id desc";
			}
			ResultSet rs = cn.executeQuery(strsql);
			list = new Vector();
			while (rs.next())
			{
				honor hr = new honor();
				hr.setId(rs.getInt("id"));
				hr.setTitle(rs.getString("title"));
				hr.setTime(rs.getString("datatimes"));
				
                list.addElement(hr);
                flag = true;
			}
			cn.closestmt();
			cn.closeconn();
			
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return flag;
		
	}
}

⌨️ 快捷键说明

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