日期:2014-05-20 浏览次数:21069 次
public static void categoryDelete(int id, boolean isLeaf) {
        Connection conn =  null ;
        Statement stmt = null ;
        ResultSet rs = null ;
        String sql_child = "select * from category where pid = " + id;
        conn = DB.getConn();
        stmt = DB.getStmt(conn);
        rs = DB.executeQuery(stmt, sql_child);
        if(!isLeaf){
            try {
                while (rs.next()) {
                     categoryDelete(rs.getInt("id"), rs.getInt("leaf")==0);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }finally{
            DB.closeRs(rs);
            DB.closeStmt(stmt);
          }
      }
      //删除该目录
    String sql_self = "delete from category where id = "+ id ;
    DB.executeUpdate(conn, sql_self);
    }