当前位置: 代码迷 >> Java Web开发 >> 尚学堂BBS2007疑问解答解决方法
  详细解决方案

尚学堂BBS2007疑问解答解决方法

热度:9548   发布时间:2013-02-25 21:22:50.0
尚学堂BBS2007疑问解答
<%!private void tree(Set<Article> articles, Connection con, int id, int grade) {
String sql = "select * from article where pid = " + id;
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt, sql);
try {
while (rs.next()) {
Article a = new Article();
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
a.setRootId(rs.getInt("rootid"));
a.setTitle(rs.getString("title"));
a.setLeaf(rs.getInt("isleaf") == 0 ? true : false);
a.setPdate(rs.getTimestamp("pdate"));
a.setGrade(grade + 1);
articles.add(a);
if (!a.isLeaf()) {
tree(articles, conn,a.getId(), grade + 1);
}

}
} catch (SQLException e) {
e.printStackTrace();
}
}%>

<%
Set<Article> articles = new HashSet<Article>();
Connection conn = DB.getConn();
tree(articles, conn, 0, 0);
DB.close(conn);
%>

不太会提问,我是跟着尚学堂BBS2007做下来的,其中在树状结构展现1的视频中,遇到上述问题,出现红色字体,有错误,报错如下:
严重: Error compiling file: /C:/Program Files/Apache Software Foundation/Tomcat 5.0/work/Catalina/localhost/ShoolWeb//org/apache/jsp\bbs_jsp.java [javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\ShoolWeb\org\apache\jsp\bbs_jsp.java:16: 找不到符号
符号: 变量 conn
位置: 类 org.apache.jsp.bbs_jsp
Statement stmt = DB.createStmt(conn);
^
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\ShoolWeb\org\apache\jsp\bbs_jsp.java:30: 找不到符号
符号: 变量 conn
位置: 类 org.apache.jsp.bbs_jsp
tree(articles, conn,a.getId(), grade + 1);
^
2 错误



我按照视频做的 ,其他的也封装好了,找不出问题,求助高手了~~~~~

------解决方案--------------------------------------------------------
Connection con,

Statement stmt = DB.createStmt(conn);

对比一下,con == conn ?
------解决方案--------------------------------------------------------
探讨
谢谢1楼,Conn 搞定了,可Set <Article>articles = newHashSet <Article>();还是红的 这个好像就不是拼写问题了,请教啊 ~~~~谢谢
  相关解决方案