zoukankan      html  css  js  c++  java
  • jsforum研究。一个比较简单的论坛。

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

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

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

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

     

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

     

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

     

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

     

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

     

    没有放web.xml文件。

     

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

     

    Sql代码  收藏代码
    1. CREATE TABLE forum_forums  
    2. (id         int(10)     NOT NULL    auto_increment,    
    3.  forum_id   int(10)         NOT NULL,  
    4.  title      text        NOT NULL,    
    5.  forum_info     text        NOT NULL,   
    6.  PRIMARY KEY (id,forum_id)  
    7. );  
    8.   
    9. CREATE TABLE forum_message   
    10. (id         int(10)     NOT NULL    auto_increment,   
    11.  forum_id   int(10)     NOT NULL,  
    12.  thread_id  int(10)     NOT NULL,   
    13.  reply_id   int(10)     NOT NULL,   
    14.  message    text        NOT NULL,    
    15.  user       text        NOT NULL,    
    16.  date_time  datetime    NOT NULL,  
    17.  PRIMARY KEY (id,forum_id,thread_id,reply_id)  
    18. );  
    19.   
    20. CREATE TABLE forum_threads   
    21. (id         int(10)     NOT NULL    auto_increment,    
    22.  forum_id   int(10)     NOT NULL,      
    23.  thread_id  int(10)     NOT NULL,     
    24.  title      text        NOT NULL,    
    25.  views      int(10)     default 0,  
    26.  PRIMARY KEY (id,forum_id,thread_id)   
    27. );  
    28.   
    29. CREATE TABLE forum_users  
    30. (id     int(10)     NOT NULL    auto_increment,  
    31.  user_name  text        NOT NULL,     
    32.  password   text        NOT NULL,  
    33.  email      text         ,  
    34.  registerdate   datetime     ,  
    35.  type   text ,  
    36.  avatar     text         ,  
    37.  member_title   text         ,  
    38.  signature  text         ,  
    39.  PRIMARY KEY (id)  
    40. );  
    41.   
    42. CREATE TABLE forum_settings  
    43. (id     int(10)     NOT NULL    auto_increment,  
    44.  dbName     text        NOT NULL,     
    45.  dbLogin    text        NOT NULL,  
    46.  dbPassword text        NOT NULL,  
    47.  forumPath  text        NOT NULL,  
    48.  forumName  text        NOT NULL,  
    49.  messagePerPage text        NOT NULL,  
    50.  PRIMARY KEY (id)  
    51. );  

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

     

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

     

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

     

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

     

    Java代码  收藏代码
    1. public void query(String SQLQuery){  
    2.     this.SQLQuery = SQLQuery;  
    3.     try {  
    4.         stmt = conn.createStatement();  
    5.         <span style="color: #ff0000;">stmt.executeQuery( SQLQuery );</span>  
    6.   
    7.     }  
    8.     catch( Exception e ){}  
    9. }  

     这个应该是:

     

    Java代码  收藏代码
    1. public void query(String SQLQuery) {  
    2.     System.out.println(SQLQuery);  
    3.     this.SQLQuery = SQLQuery;  
    4.     try {  
    5.         stmt = conn.createStatement();  
    6.         <span style="color: #ff0000;">stmt.executeUpdate(SQLQuery);</span>  
    7.   
    8.           
    9.     } catch (Exception e) {  
    10.         e.printStackTrace();  
    11.     }  
    12. }  

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

     

     

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

    注意字段的not null属性,因为之前调试了半天,最后发现是由于数据库的影响,导致stmt.executeUpdate()总是执行不成功。 

  • 相关阅读:
    Chrome技巧
    jQuery中.bind() .live() .delegate() .on()的区别
    BRAVEHEART勇敢的心威廉姆华莱士战场演讲
    CSS3小模块hover左右交替互换动画
    sublime text 3
    百度图片搜索页的图片展示列表模块jquery效果
    出埃及记:摩西劈开红海
    用位数组计算整数中1的个数
    Using the XPath Wrappers
    【转】为Xcode 4挑选自己喜欢的字体和颜色(Panic Sans)
  • 原文地址:https://www.cnblogs.com/zhuxiangguo/p/2198872.html
Copyright © 2011-2022 走看看