PreparedStatement ps=null;
ResultSet rs=null;StringpreStr="";for(inti=0;i
preStr+="****";
}
try{Stringsql="select * from article where pid ="+id;
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();while(rs.next()){
str+="
"+rs.getInt("id")+""+preStr+rs.getString("cont")+"";if(rs.getInt("isleaf")!=0){tree(conn,rs.getInt("id"),level+1);
}
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{if(rs!=null) {
rs.close();
rs=null;
}if(ps!=null) {
ps.close();
ps=null;
}
}catch(SQLException e2){
e2.printStackTrace();
}
}
}%>
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs","root","root");
PreparedStatement ps=conn.prepareStatement("select * from article where pid=0");
ResultSet rs=ps.executeQuery();while(rs.next()){
str+="
"+rs.getInt("id")+""+rs.getString("cont")+"";if(rs.getInt("isleaf")!=0){tree(conn,rs.getInt("id"),1);
}
}
rs.close();
ps.close();
conn.close();%>
ShowArticleTree