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

📄 topicdisp.java

📁 该系统利用Java实现简单论坛功能
💻 JAVA
字号:
package ch11.bean;

import java.util.*;
import java.sql.Connection;
import java.sql.ResultSet;
import ch11.util.*;

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.execQuery(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.execQuery(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 response where topicid=" + topic.id;
			rsNest = db.execQuery(strSql);
			if (rsNest.next()){
				topic.setReCount(rsNest.getInt(1));
			}
				
        	strSql = "select * from response where topicid=" + topic.id + " order by time desc" ;
			rsNest = db.execQuery(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;
	}
		
}

⌨️ 快捷键说明

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