日期:2014-05-16  浏览次数:20306 次

jsforum研究。一个比较简单的论坛。

突然想看看论坛是怎么写的。

回想起以前。用jforum。安装使用。在看看那些代码。很多。

觉得很麻烦。自己需要的论坛也没有要求那么复杂。

就是需要简单的发帖。回帖。

?

进行管理。就可以了。功能越简单越好。

?

于是发现了。jsforum。功能超级简单。

?

其中也发现一些问题。进行简单的修改。

?

首先是在web.xml添加servlet。(见附件)

?

没有放web.xml文件。

?

数据库的创建脚本里面。都是用的text字段。这个倒是不用担心最大长度。

?

CREATE TABLE forum_forums
(id 		int(10)		NOT NULL	auto_increment,  
 forum_id 	int(10)     	NOT NULL,
 title 		text 		NOT NULL,  
 forum_info 	text 		NOT NULL, 
 PRIMARY KEY (id,forum_id)
);

CREATE TABLE forum_message 
(id 		int(10)		NOT NULL	auto_increment, 
 forum_id 	int(10)		NOT NULL,
 thread_id 	int(10)		NOT NULL, 
 reply_id 	int(10)		NOT NULL, 
 message 	text		NOT NULL,  
 user 		text		NOT NULL,  
 date_time 	datetime 	NOT NULL,
 PRIMARY KEY (id,forum_id,thread_id,reply_id)
);

CREATE TABLE forum_threads 
(id 		int(10) 	NOT NULL	auto_increment,  
 forum_id 	int(10) 	NOT NULL,    
 thread_id 	int(10) 	NOT NULL,   
 title 		text 		NOT NULL,  
 views 		int(10) 	default 0,
 PRIMARY KEY (id,forum_id,thread_id) 
);

CREATE TABLE forum_users
(id		int(10)		NOT NULL	auto_increment,
 user_name	text		NOT NULL,	
 password	text		NOT NULL,
 email		text		 ,
 registerdate	datetime	 ,
 type	text ,
 avatar		text		 ,
 member_title	text		 ,
 signature	text		 ,
 PRIMARY KEY (id)
);

CREATE TABLE forum_settings
(id		int(10)		NOT NULL	auto_increment,
 dbName		text		NOT NULL,	
 dbLogin	text		NOT NULL,
 dbPassword	text		NOT NULL,
 forumPath	text		NOT NULL,
 forumName	text		NOT NULL,
 messagePerPage text		NOT NULL,
 PRIMARY KEY (id)
);

?数据库里面forum_user里面少了一个type字段。

?

在数据java类里面也有过小小的问题。mysql的驱动定义。

?

Class.forName("com.mysql.jdbc.Driver");

?

在执行的时候的方法也不对。

?

    public void query(String SQLQuery){
    	this.SQLQuery = SQLQuery;
        try {
        	stmt = conn.createStatement();
            stmt.executeQuery( SQLQuery );

        }
        catch( Exception e ){}
    }

?这个应该是:

?

	public void query(String SQLQuery) {
		System.out.println(SQLQuery);
		this.SQLQuery = SQLQuery;
		try {
			stmt = conn.createStatement();
			stmt.executeUpdate(SQLQuery);

			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

?明明就是是数据库插入删除的的操作。名字是query。应该叫executeXXX什么吧。

?

?

总之修改了之后。是可以用来。


?

功能什么的都是最简单的方式实现的。自己可以看看研究下。

明白了这个就可以自己写点东西了。

?

?

附件里面是整个工程。

?

?