请介绍一下News.java和Function.java是什么关系?为什么我修改了一下查询语句后只能显示第一页,第二页为空记录?
public String ArticleList(String toPage, String pageNum, String pageSize,String big) {
try {
Connection Conn = ConnDB.getConnection(); //获取数据库
Statement stmt = Conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); //创建数据库连接状态
ResultSet rs = null; //创建结果集查询
StringBuffer resultData = new StringBuffer(); //创建结果字符串集合
String para="";
if (!big.equals(null)||!big.eauals("")){
para="and BigClassName='"+ big +"'";
}
int intPageNum=Integer.parseInt(pageNum);
int ingPagesize=Integer.parseInt(pageSize);
/** 下行做了修改 **/
String sSql = "select top "+ingPagesize+" NewsId,NewsTitle from News where NewsId not in(select top "+(ingPagesize * (intPageNum-1))+" NewsId from News where NewsId>0 "+ para +" order by NewsTime desc) "+ para +" order by NewsTime desc";//创建数据库查询语句
//System.out.println(sSql);
rs = stmt.executeQuery(sSql); //执行数据库查询
resultData=Fun.ArticleList(resultData,rs,toPage,pageNum, pageSize); //获取返回分页结果
rs.close(); //关闭结果集查询连接
stmt.close(); //关闭数据库连接
Conn.close(); //关闭数据库
return resultData.toString(); //给前台返回结果集
} catch (Exception e) {
e.printStackTrace();
return "No"; //若获取数据库失败,返回“No”
}
}