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

📄 topicdisp.java

📁 mysql+stuts jdbc连接数据库 BBS论坛
💻 JAVA
字号:
package j2eebbs;

import java.sql.ResultSet;
import java.util.Vector;

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 forumid) throws Exception {
		ResultSet rs;
		String strSql = null;
		int iRecordCount = 0;

		strSql = "select count(*) from topic where forumid=" + forumid;
		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 iCurRecord = 0;

		strSql = "select * from topic where forumid=" + forumid
				+ " order by id 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("title"));
			topic.setContent(rs.getString("content"));
			topic.setAuthor(rs.getString("author"));
			topic.setSubmittime(rs.getString("submittime"));
			topic.setForumid(forumid);
			topic.setLastTalk(rs.getString("submittime"));

			strSql = "select count(*) from response where topicid=" + topic.id;
			rsNest = db.OpenSql(strSql);
			if (rsNest.next()) {
				topic.setReCount(rsNest.getInt(1));
			}

			strSql = "select * from response where topicid=" + topic.id
					+ " order by id desc";
			rsNest = db.OpenSql(strSql);
			if (rsNest.next()) {
				topic.setLastTalk(rsNest.getString("submittime"));
			}

			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 + -