日期:2014-05-17  浏览次数:20666 次

java.lang.NullPointerException问题,各位大侠帮忙看看,在线等着
<%@page pageEncoding="GB18030" %>
<%@page import=" java.sql.*" %>
<%@page import=" java.util.*" %>
<%@page import="java.io.*" %>
<%@page import="com.bjsxt.bbs.*" %>
<%!
  private void tree(Set<Article> articles,Connection conn,int id,int grade){
  String sql = "select * from atticle 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);
  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);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0051)http://bbs.chinajavaworld.com/forum.jspa -->
<HTML>
<HEAD>
<TITLE>论坛: Java语言*初级版</TITLE>
<META content="text/html; charset=UTF-8" http-equiv=content-type>
<LINK 
rel=stylesheet type=text/css href="images/style.jsp">
<META name=GENERATOR content="MSHTML 8.00.7600.16535">
</HEAD>
<BODY>
<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
  <TD width="1%"><A href="http://bbs.chinajavaworld.com/index.jspa">&ldquo;&rdquo;<IMG 
  border=0 alt=JAVA中文世界论坛|JAVA开发者论坛 src="images/header-left.gif" 
  width=199 height=38></A></TD>
  <TD width="98%"><IMG border=0 alt="" 
  src="images/header-stretch.gif" width="100%" height=38></TD>
  <TD width="1%"><IMG border=0 alt="" src="images/header-right.gif" 
  width=5 height=38></TD>
  </TR>
  </TBODY>
</TABLE>
<BR>
<BR>
<DIV id=jive-accountbox class=clearfix>
  <DL>
  <DT>欢迎, 游客 </DT>
  <DD><A class=jive-acc-login 
  href="http://bbs.chinajavaworld.com/login!withRedirect.jspa">登录 / 注册</A> </DD>
  <DD><A class=jive-acc-cp 
  href="http://bbs.chinajavaworld.com/guestsettings!default.jspa">游客设置</A> </DD>
  </DL>
</DIV>
<P class=jive-page-title>论坛: Java语言*初级版</P>
<LINK title=RSS 
rel=