Implementation of the Forum tree structure of the algorithm many, specific you can go to www.chinaasp.com full-text search query. My current JSP forum is also one of the following: Do not have to implement the tree structure of the algorithm, now I will be the forum tree structure of the specific algorithm and you introduce, and everyone to communicate.
1, the structure of the demo table:
Table Name: mybbslist
field Data type description
BBSID Automatic Numbering
Rootid Int Root Post ID, which itself is the root post Rootid = ID
FID INT parent Post ID, the ID of the previous post, if the root thread fid = 0
DEPTH Int Root Post level=0, other depending on the depth of the reply increment
Bbssubject Char Theme
2. To create a table:
create table mybbslist (
forumID int(20) not null,
bbsID int auto_increment primary key,
rootid int(20) not null,
fid int(20) not null,
depth int(20) not null,
userID int(20) not null,
bbsUser varchar(24) not null,
bbsSubject varchar(100) not null,
bbsContent text,
bbsTime varchar(30),
bbsRead int(20),
bbsReply int(20),
INDEX forumID (forumID))
3, connect the MySQL database bean
Package NetZero;
Import java.sql.*;
public class MyDB
{
String drivername = "Org.gjt.mm.mysql.Driver";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String connurl= "Jdbc:mysql://localhost/mybbs?user=root&password=how&useunicode=true&characterencode =8859_1 ";
String connurl= "Jdbc:mysql://localhost/netzerobbs?user=root&password=how";
Public MyDB ()
{
Try
{
Class.forName (drivername);
}
catch (Java.lang.ClassNotFoundException e)
{
System.err.println ("NetZero (String):" + e.getmessage ());
}
}
Public ResultSet executequery (String sql) throws SQLException
{
conn = Drivermanager.getconnection (Connurl);
stmt = Conn.createstatement ();
rs = stmt.executequery (SQL);
Return RS;
}
public boolean closeconn ()
{
Try
{
if (rs!=null) rs.close ();
if (stmt!=null) stmt.close ();
if (conn!=null) conn.close ();
return true;
}
catch (SQLException ex)
{
System.err.println ("Closeconn:" + ex.getmessage ());
return false;
}
}
}