资源简介
一个完整的JAVA源码文件,供初学者搭建项目实践思想!

代码片段和文件信息
import java.sql.*;
public class ArticleTree {
public static void main(String[] args) {
new ArticleTree().show();
}
public void show() {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName(“com.mysql.jdbc.Driver“);
conn = DriverManager
.getConnection(“jdbc:mysql://localhost/bbs?user=root&password=root“);
stmt = conn.createStatement();
rs = stmt.executeQuery(“select * from article where pid = 0“);
while(rs.next()){
System.out.println(rs.getString(“cont“));
tree(conn rs.getInt(“id“) 1);
}
} catch(ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private void tree(Connection conn int id int level) {
Statement stmt = null;
ResultSet rs = null;
StringBuffer strPre = new StringBuffer(““);
for(int i=0; i strPre.append(“ “);
}
try {
stmt = conn.createStatement();
String sql = “select * from article where pid = “ + id;
rs = stmt.executeQuery(sql);
while(rs.next()) {
System.out.println(strPre + 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(stmt != null) {
stmt.close();
stmt = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 463 2006-11-07 08:27 source\BBS\.classpath
文件 848 2006-11-07 08:27 source\BBS\.project
文件 98 2006-11-09 09:55 source\BBS\.settings\org.eclipse.core.resources.prefs
文件 330 2006-11-07 08:27 source\BBS\.settings\org.eclipse.jdt.core.prefs
文件 288 2006-11-07 08:27 source\BBS\.settings\org.eclipse.jst.common.project.facet.core.prefs
文件 394 2006-11-07 08:27 source\BBS\.settings\org.eclipse.wst.common.component
文件 269 2006-11-07 08:27 source\BBS\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 998 2006-11-07 08:33 source\BBS\SQL\bbs.sql
文件 1733 2006-11-09 11:01 source\BBS\WebContent\Delete.jsp
文件 2295 2006-11-09 09:20 source\BBS\WebContent\images\bot_footer_bar.gif
文件 1788 2006-11-09 09:20 source\BBS\WebContent\images\client_login_bot_arc.gif
文件 9078 2006-11-09 09:20 source\BBS\WebContent\images\client_login_left_arc.gif
文件 20613 2006-11-09 09:20 source\BBS\WebContent\images\client_login_main_pic.jpg
文件 4585 2006-11-09 09:20 source\BBS\WebContent\images\client_login_message_bar.gif
文件 1328 2006-11-09 09:20 source\BBS\WebContent\images\client_login_submit.gif
文件 49 2006-11-09 09:20 source\BBS\WebContent\images\client_login_text_bg.gif
文件 3934 2006-11-09 09:20 source\BBS\WebContent\images\client_login_ti
文件 3263 2006-11-09 09:20 source\BBS\WebContent\images\interior_bot_nav_bar.gif
文件 2437 2006-11-09 09:20 source\BBS\WebContent\images\nav_about_sim.gif
文件 88 2006-11-09 09:20 source\BBS\WebContent\images\nav_arrows.gif
文件 2356 2006-11-09 09:20 source\BBS\WebContent\images\nav_client_access.gif
文件 3289 2006-11-09 09:20 source\BBS\WebContent\images\nav_contact_request.gif
文件 2217 2006-11-09 09:20 source\BBS\WebContent\images\nav_government_contracting.gif
文件 1478 2006-11-09 09:20 source\BBS\WebContent\images\nav_homepage.gif
文件 1458 2006-11-09 09:20 source\BBS\WebContent\images\nav_join_our_team.gif
文件 2597 2006-11-09 09:20 source\BBS\WebContent\images\nav_our_services.gif
文件 4350 2006-11-09 09:20 source\BBS\WebContent\images\sim_logo_top.gif
文件 3739 2006-11-09 09:20 source\BBS\WebContent\images\sim_st
文件 43 2006-11-09 09:20 source\BBS\WebContent\images\spacer.gif
文件 2759 2006-11-09 09:20 source\BBS\WebContent\images\top_nav_bar.gif
............此处省略78个文件信息
- 上一篇:Java版凸包问题解决代码
- 下一篇:Java深入微服务原理改造房产销售平台.rar
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- 美食天下项目Android版源码和Web版源码
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- u-blox_Android_GNSS_Driver_v3.10驱动源码+中
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- 个人根据Android移动开发案例详解手写
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 基于JSP的学生宿舍管理系统(源码 数
- mysql jsp网站源码下载
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
评论
共有 条评论