TopicDisp.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:2k
- package StudyBbs;
- import java.util.*;
- import java.sql.Connection;
- import java.sql.ResultSet;
- public class TopicDisp extends Topic{
-
- private int reCount;
- private String lastTalk ;
-
- public TopicDisp(){
- }
-
- public int getReCount(){
-
- return reCount;
-
- }
-
- public void setReCount(int reCount) {
-
- this.reCount = reCount;
- }
-
- public String getLastTalk(){
-
- return lastTalk;
- }
- public void setLastTalk(String lastTalk) {
-
- this.lastTalk = lastTalk;
- }
-
- public int GetTopicCount(DB db,int sortid) throws Exception{
- ResultSet rs,rsNest;
- String strSql=null;
- int iRecordCount=0;
-
- strSql = "select count(*) from topic where sortid=" + sortid ;
- rs = db.OpenSql(strSql);
- if ( rs.next()) {
- iRecordCount=rs.getInt(1);
- }
- return iRecordCount;
- }
-
- public Vector search(DB db,int pageid) throws Exception{
- Vector Topics = new Vector();
- ResultSet rs,rsNest;
- String strSql=null;
- int iRecordCount=0;
- int iCurRecord=0;
-
- strSql = "select * from topic where sortid=" + sortid + " order by time desc";
- rs = db.OpenSql(strSql);
- int iCount=0;
- iCurRecord=pageid * Constants.TOPIC_PAGE_SIZE + 1;
- rs.absolute(iCurRecord);
- do{
- TopicDisp topic = new TopicDisp();
-
- topic.setId(rs.getInt("id"));
- topic.setTitle ( rs.getString("topicname"));
- topic.setContent ( rs.getString("topiccontent"));
- topic.setOwner ( rs.getString("owner"));
- topic.setTime ( rs.getString("time"));
- topic.setSortid ( sortid);
- topic.setLastTalk (rs.getString("time"));
-
- strSql = "select count(*) from responses where topicid=" + topic.id;
- rsNest = db.OpenSql(strSql);
- if (rsNest.next()){
- topic.setReCount(rsNest.getInt(1));
- }
-
- strSql = "select * from responses where topicid=" + topic.id + " order by time desc" ;
- rsNest = db.OpenSql(strSql);
- if (rsNest.next()){
- topic.setLastTalk (rsNest.getString("time"));
- }
-
- Topics.add(topic);
- iCount++;
- if (iCount>=Constants.TOPIC_PAGE_SIZE){
- break;
- }
- }while(rs.next());
- return Topics;
- }
-
- }