日期:2014-05-18 浏览次数:20847 次
package com.bean;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.util.Constant;
import com.util.DBO;
public class NewsBean {
private String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
private List list;
private ResultSet rs = null;
//不置顶新闻分页
private int EVERYPAGENUM = 2;
private int count = -1;
private int qq = 0;
private String sql="select count(*) from news where up='0' ";
private String sql2="select * from news where up='0' order by id desc ";
private String sql3="select count(*) from news where up='1' ";
private String sql4="select * from news where up='1' order by id desc ";
public void setEVERYPAGENUM(int EVERYPAGENUM){
this.EVERYPAGENUM=EVERYPAGENUM;
}
public int getMessageCount() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery(sql);
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return -1;
} finally {
dbo.close();
}
}
public int getPageCount() { //得到共多少页(根据每页要显示几条信息)
if (count % EVERYPAGENUM == 0) {
return count / EVERYPAGENUM;
} else {
return count / EVERYPAGENUM + 1;
}
}
public List getMessage(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list =