用JSP写的论坛源代码 走过路过的各位千万不要错过啊!!!!
源代码在线查看: forumbean.java
package bbs.beans.displayplan;
import java.sql.*;
import java.util.Vector;
import java.lang.Integer;
import bbs.beans.displayplan.PageBean;
public class ForumBean extends PageBusiness
{
public ForumBean()
{
super();
v=new Vector();
}
//获得所有的记录
public int getAvailableCount()throws Exception
{
return this.getAvailableCountHelper();
}
//查询数据库,获得要显示的信息,然后通过PageBean返回.当parentid的返回值为0表示要显示一个版的主题帖
//当parentid的返回值不为0时表示要显示一个主题帖的回复帖
public PageBean listData(String page,String parentid,String boardid)throws Exception
{
this.parentid =Integer.parseInt(parentid);
this.boardid =Integer.parseInt(boardid);
PageBean pageBean=new PageBean(this);
int num=Integer.parseInt(page);//.获得当前的页面号
int i=0;
try
{ if(this.parentid==0)
{
if(num==1)
{result=stm.executeQuery("select * from topicplan,userinfo where state>=5 and state7 and topicplan.userid=userinfo.userid order by state asc,pubtime desc");
while(result.next())
{
Object[] obj=new Object[9];
obj[0]=result.getString("parentid") ;
obj[1]=result.getString("username");
obj[2]=result.getString("clicksnum");
obj[3]=result.getString("pubtime");
obj[4]=result.getString("topic");
obj[5]=result.getString("state");
obj[6]=result.getString("replynum");
obj[7]=result.getString("moodnum");
obj[8]=result.getString("boardid");
(this.v).add(obj);
}//搜索固顶帖
result=stm.executeQuery("select * from topicplan,userinfo where state=7 and boardid="+this.boardid+" and topicplan.userid=userinfo.userid order by pubtime desc");
while(result.next())
{
Object[] obj=new Object[9];
obj[0]=result.getString("parentid") ;
obj[1]=result.getString("username");
obj[2]=result.getString("clicksnum");
obj[3]=result.getString("pubtime");
obj[4]=result.getString("topic");
obj[5]=result.getString("state");
obj[6]=result.getString("replynum");
obj[7]=result.getString("moodnum");
obj[8]=result.getString("boardid");
(this.v).add(obj);
}//搜索区固顶帖
}
result=stm.executeQuery("select top "+num*pageBean.rowsperpage+" * from topicplan,userinfo where boardid="+this.boardid+" and state while(result.next())
{
if(i>(num-1)*pageBean.rowsperpage-1)
{
Object[] obj=new Object[9];
obj[0]=result.getString("parentid") ;
obj[1]=result.getString("username");
obj[2]=result.getString("clicksnum");
obj[3]=result.getString("pubtime");
obj[4]=result.getString("topic");
obj[5]=result.getString("state");
obj[6]=result.getString("replynum");
obj[7]=result.getString("moodnum");
obj[8]=result.getString("boardid");
(this.v).add(obj);
}
i++;
}
}
else
{if(num==1)
{ result=stm.executeQuery("select * from topicplan,userinfo where topicplan.parentid="+this.parentid+" and topicplan.boardid="+this.boardid+" and topicplan.userid=userinfo.userid");
if(result.next())
{Object[] obj=new Object[14];
obj[0]=result.getString("parentid") ;
obj[1]="0";
obj[2]=result.getString("userid");
obj[3]=result.getString("pubtime");
obj[4]=result.getString("topic");
obj[5]=result.getString("text");
obj[6]=result.getString("moodnum");
obj[7]=result.getString("username");
obj[8]=result.getString("usersex");
obj[9]=result.getString("usersign");
obj[10]=result.getString("online");
obj[11]=result.getString("plans");
obj[12]=result.getString("registerdate");
obj[13]=result.getString("facenum");
(this.v).add(obj);}
}
result=stm.executeQuery("select top "+num*pageBean.rowsperpage+" * from replyplan,userinfo where replyplan.parentid="+
this.parentid+" and replyplan.boardid="+this.boardid+
" and replyplan.userid=userinfo.userid order by replyplan.childid asc");
while(result.next())
{
if(i>(num-1)*pageBean.rowsperpage-1)
{
Object[] obj=new Object[14];
obj[0]=result.getString("parentid") ;
obj[1]=result.getString("childid");
obj[2]=result.getString("userid");
obj[3]=result.getString("pubtime");
obj[4]=result.getString("topic");
obj[5]=result.getString("text");
obj[6]=result.getString("moodnum");
obj[7]=result.getString("username");
obj[8]=result.getString("usersex");
obj[9]=result.getString("usersign");
obj[10]=result.getString("online");
obj[11]=result.getString("plans");
obj[12]=result.getString("registerdate");
obj[13]=result.getString("facenum");
(this.v).add(obj);
}
i++;
}
}
stm.close();
pageBean.curpage=num;
pageBean.v=this.v;
return pageBean;
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
public Vector getResult()throws Exception
{
return this.v;
}
}