数据库的结构和对应的POJO
数据库结构    

T_User    
查看复制到剪切板打印
/*        
MySQL Data Transfer        
Source Host: localhost        
Source Database: notepad        
Target Host: localhost        
Target Database: notepad        
Date: 2008-7-19 8:44:39        
*/
        
    
SET FOREIGN_KEY_CHECKS=0;        
-- ----------------------------        
-- Table structure for t_user        
-- ----------------------------        
CREATE TABLE `t_user` (        
    `Id` int(11) NOT NULL auto_increment COMMENT '编号',        
    `username` varchar(20) collate utf8_unicode_ci NOT NULL default '' COMMENT '用户名',        
    `password` varchar(32) collate utf8_unicode_ci NOT NULL default '' COMMENT '密码',        
    PRIMARY KEY    (`Id`),        
    UNIQUE KEY `username` (`username`)        
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;        
    
-- ----------------------------        
-- Records        
-- ----------------------------        
INSERT INTO `t_user` VALUES ('1', 'admin', 'admin');    

/*
MySQL Data Transfer
Source Host: localhost
Source Database: notepad
Target Host: localhost
Target Database: notepad
Date: 2008-7-19 8:44:39
*/


SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_user
-- ----------------------------
CREATE TABLE `t_user` (
    `Id` int(11) NOT NULL auto_increment COMMENT '编号',
    `username` varchar(20) collate utf8_unicode_ci NOT NULL default '' COMMENT '用户名',
    `password` varchar(32) collate utf8_unicode_ci NOT NULL default '' COMMENT '密码',
    PRIMARY KEY    (`Id`),
    UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- ----------------------------
-- Records    
-- ----------------------------
INSERT INTO `t_user` VALUES ('1', 'admin', 'admin');

T_Post    
查看复制到剪切板打印
/*        
MySQL Data Transfer        
Source Host: localhost        
Source Database: notepad        
Target Host: localhost        
Target Database: notepad        
Date: 2008-7-19 8:44:45        
*/
        
    
SET FOREIGN_KEY_CHECKS=0;        
-- ----------------------------        
-- Table structure for t_post        
-- ----------------------------        
CREATE TABLE `t_post` (        
    `Id` int(11) NOT NULL auto_increment COMMENT '编号',        
    `IdParent` int(11) NOT NULL default '0' COMMENT '上级编号',        
    `UserId` int(11) NOT NULL COMMENT '用户',        
    `Title` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT '标题',        
    `Content` varchar(2000) collate utf8_unicode_ci NOT NULL COMMENT '内容',        
    `Datetime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '日期',        
    PRIMARY KEY    (`Id`),        
    KEY `UserId` (`UserId`),        
    KEY `IdParent` (`IdParent`),        
    CONSTRAINT `t_post_ibfk_1` FOREIGN KEY (`UserId`) REFERENCES `t_user` (`Id`)        
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;        
    
-- ----------------------------        
-- Records        
-- ----------------------------        
INSERT INTO `t_post` VALUES ('1', '0', '1', '和老紫竹一起学java', '和老紫竹一起学java的留言板功能', '2008-07-19 07:59:57');        
INSERT INTO `t_post` VALUES ('2', '1', '1', '我们的回复标题', '我们的回复内容', '2008-07-19 08:01:22');    

/*
MySQL Data Transfer
Source Host: localhost
Source Database: notepad
Target Host: localhost
Target Database: notepad
Date: 2008-7-19 8:44:45
*/


SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for t_post
-- ----------------------------
CREATE TABLE `t_post` (
    `Id` int(11) NOT NULL auto_increment COMMENT '编号',
    `IdParent` int(11) NOT NULL default '0' COMMENT '上级编号',
    `UserId` int(11) NOT NULL COMMENT '用户',
    `Title` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT '标题',
    `Content` varchar(2000) collate utf8_unicode_ci NOT NULL COMMENT '内容',
    `Datetime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '日期',
    PRIMARY KEY    (`Id`),
    KEY `UserId` (`UserId`),
    KEY `IdParent` (`IdParent`),
    CONSTRAINT `t_post_ibfk_1` FOREIGN KEY (`UserId`) REFERENCES `t_user` (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- ----------------------------
-- Records    
-- ----------------------------
INSERT INTO `t_post` VALUES ('1', '0', '1', '和老紫竹一起学java', '和老紫竹一起学java的留言板功能', '2008-07-19 07:59:57');
INSERT INTO `t_post` VALUES ('2', '1', '1', '我们的回复标题', '我们的回复内容', '2008-07-19 08:01:22');


对应的POJO    
User.java    
查看复制到剪切板打印
package net.java2000.notepad;        
    
/**    
* 用户信息。这个版本只需要记录最简单的用户名和密码即可    
*        
* @author 赵学庆,Java世纪网([url]http://www.java2000.net[/url])    
*        
*/
    
public class User {        
     private long id;        
     private String username;        
     private String password;        
    
     public long getId() {        
         return id;        
    }        
    
     public void setId( long id) {        
         this.id = id;        
    }        
    
     public String getUsername() {        
         return username;        
    }        
    
     public void setUsername(String username) {        
         this.username = username;        
    }        
    
     public String getPassword() {        
         return password;        
    }        
    
     public void setPassword(String password) {        
         this.password = password;        
    }        
}    

package net.java2000.notepad;

/**
* 用户信息。这个版本只需要记录最简单的用户名和密码即可
*    
* @author 赵学庆,Java世纪网([url]http://www.java2000.net[/url])
*    
*/

public class User {
     private long id;
     private String username;
     private String password;

     public long getId() {
         return id;
    }

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

     public String getUsername() {
         return username;
    }

     public void setUsername(String username) {
         this.username = username;
    }

     public String getPassword() {
         return password;
    }

     public void setPassword(String password) {
         this.password = password;
    }
}

Post.java    
查看复制到剪切板打印
package net.java2000.notepad;        
    
import java.sql.Timestamp;        
    
/**    
* 留言数据。包括发言和回复,只记录最基本的信息    
*        
* @author 赵学庆,Java世纪网([url]http://www.java2000.net[/url])    
*        
*/
    
public class Post {        
     // 编号        
     private long id;        
    
     // 上级ID,对于发言,此ID为0,对于回复则指向发言的ID        
     private long idParent;        
    
     // 发言的用户        
     private User user;        
     // 标题        
     private String title;        
    
     // 内容        
     private String content;        
     // 发言时间        
     private Timestamp datetime;        
    
     public long getId() {        
         return id;        
    }        
    
     public void setId( long id) {        
         this.id = id;        
    }        
    
     public long getIdParent() {        
         return idParent;        
    }        
    
     public void setIdParent( long idParent) {        
         this.idParent = idParent;        
    }        
    
     public User getUser() {        
         return user;        
    }        
    
     public void setUser(User user) {        
         this.user = user;        
    }        
    
     public String getTitle() {        
         return title;        
    }        
    
     public void setTitle(String title) {        
         this.title = title;        
    }        
    
     public String getContent() {        
         return content;        
    }        
    
     public void setContent(String content) {        
         this.content = content;        
    }        
    
     public Timestamp getDatetime() {        
         return datetime;        
    }        
    
     public void setDatetime(Timestamp datetime) {        
         this.datetime = datetime;        
    }        
    
}    

package net.java2000.notepad;

import java.sql.Timestamp;

/**
* 留言数据。包括发言和回复,只记录最基本的信息
*    
* @author 赵学庆,Java世纪网([url]http://www.java2000.net[/url])
*    
*/

public class Post {
     // 编号
     private long id;

     // 上级ID,对于发言,此ID为0,对于回复则指向发言的ID
     private long idParent;

     // 发言的用户
     private User user;
     // 标题
     private String title;

     // 内容
     private String content;
     // 发言时间
     private Timestamp datetime;

     public long getId() {
         return id;
    }

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

     public long getIdParent() {
         return idParent;
    }

     public void setIdParent( long idParent) {
         this.idParent = idParent;
    }

     public User getUser() {
         return user;
    }

     public void setUser(User user) {
         this.user = user;
    }

     public String getTitle() {
         return title;
    }

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

     public String getContent() {
         return content;
    }

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

     public Timestamp getDatetime() {
         return datetime;
    }

     public void setDatetime(Timestamp datetime) {
         this.datetime = datetime;
    }

}