(JSP + MySQL database to create a message book, first to create a MySQL database, on the use of MySQL Please download the http://pinghui.51.net/download/012mysql.chm tutorial. Now, for the purpose of illustration, we assume that the database has been created and the database name is pinghui, where the comment table records the message.
The database structure is:
+ ----------- + ------------- + ------ + ----- + --------------------- + ---------------- +
| Field | Type | Null | Key | Default | Extra |
+ ----------- + ------------- + ------ + ----- + --------------------- + ---------------- +
| Userid | int (11) | PRI | 0 | auto_increment |
| Username | char (20) |
| Sex | char (2) |
| Address | char (40) | YES | NULL |
| Ip | char (15) |
| Post | int (11) | YES | 0 |
| Oicq | int (11) | YES | 0 |
| Icq | int (11) | YES | 0 |
| Telnumber | char (30) | YES | NULL |
| Comment | text | NULL |
| Time | datetime | 0000-00-00 00:00:00 |
+ ----------- + ------------- + ------ + ----- + --------------------- + ---------------- +
If you think creating a database is too troublesome
The statement for creating a database is:
Drop database if exists pinghui;
Create database pinghui;
USE pinghui;
Create table comment (
Userid int not null default 0 AUTO_INCREMENT primary key,
Username char (20) not null,
Sex char (2 ),
Address char (40 ),
Ip char (15) not null,
Post int DEFAULT 0,
Oicq int DEFAULT 0,
Icq int DEFAULT 0,
Telnumber char (30 ),
Comment text not null,
Time datetime NOT NULL
);
Insert into comment (username, ip, comment, time) VALUES ("pinghui", "127.0.0.1 ",
"Hello, please go to pinghui free space to view information! ", Now ());
Insert into comment (username, sex, address, ip, post, oicq, icq, telnumber, comment, time)
Values ('pinghui', 'male', 'address', '2017. 0.0.1 ', 127, 74875874, 0531, '2017-8605449 ',
'Hello, please go to pinghui free space to view your message! Thank you! ', Now ());
With the database, our explanation below will be more convenient. Continue to establish the message book