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

📄 topic.java

📁 论坛的通用版本,是基于eclipse+struts来设计的,他提供了游客,用户和管理员三类,功能有发表话题,发表回复,注册登陆,用户管理,等等..任何想加如到自己系统的朋友都可以使用!
💻 JAVA
字号:
package j2eebbs;

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

public class Topic {

	protected int id;

	protected String title;

	protected String content;

	protected String author;

	protected String submittime;

	protected int forumid;

	public Topic() {
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getForumid() {
		return forumid;
	}

	public void setForumid(int forumid) {
		this.forumid = forumid;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSubmittime() {
		return submittime;
	}

	public void setSubmittime(String submittime) {
		this.submittime = submittime;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public boolean insert(DB db) throws Exception {
		String strSql;
		ResultSet rs;
		int iMaxId;
		strSql = "Select max(id) From topic";
		rs = db.OpenSql(strSql);
		if (rs.next()) {
			iMaxId = rs.getInt(1) + 1;
		} else {
			iMaxId = 1;
		}
		GregorianCalendar calendar = new GregorianCalendar();
		int year = calendar.get(Calendar.YEAR);
		int month = calendar.get(Calendar.MONTH);
		int day = calendar.get(Calendar.DAY_OF_MONTH);

		String submittime = year + "-" + month + "-" + day;

		strSql = "insert into topic values(" + iMaxId + ",'" + title + "','"
				+ content + "','" + author + "','" + submittime + "'," + forumid
				+ ")";
		if (db.ExecSql(strSql) == 0) {
			return false;
		} else {
			return true;
		}

	}

	public static Vector search(DB db, String title) throws Exception {
		Vector Topics = new Vector();
		ResultSet rs;
		String strSql = null;

		strSql = "select * from topic where title like '%" + title
				+ "%'";
		rs = db.OpenSql(strSql);

		while (rs.next()) {
			Topic topic = new Topic();

			topic.setId(rs.getInt("id"));
			topic.setTitle(rs.getString("title"));
			topic.setAuthor(rs.getString("author"));

			Topics.add(topic);
		}

		return Topics;
	}

	public static boolean delete(DB db, String id) throws Exception {
		String strSql;
		strSql = "delete from topic where id=" + id;
		if (db.ExecSql(strSql) == 0) {
			return false;
		} else {
			return true;
		}
	}

}

⌨️ 快捷键说明

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