国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

樹形結構的實現

2019-11-18 15:28:08
字體:
來源:轉載
供稿:網友

本例采用access做為實例,所有還有很多要改進的地方。 
請讀者自已改進 

package PRodUCt; 
import java.sql.*; 
public class ConnectDB{ 
String strDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; 
String strConnstr="jdbc:odbc:product"; 
Connection conn=null; 
ResultSet rs=null; 
Statement stmt=null; 
// Statement stmt=null; 
//構造函數 
public ConnectDB(){ 
try{ 
Class.forName(strDBDriver); conn=DriverManager.getConnection(strConnstr); 
stmt=conn.createStatement(); 

catch(Exception e){ 
System.out.println(e); 



public ResultSet execute(String sql){ 
rs=null; 
try{ 

rs=stmt.executeQuery(sql); 

catch(SQLException e){ 
System.out.println(e.getMessage()); 

return rs; 


public Connection getConnection(){ 
return conn; 


public boolean close(){ 
try{ 
if(this.rs!=null){ 
this.rs.close(); 

if(stmt!=null){ 
this.stmt.close(); 

if(conn!=null){ 
this.conn.close(); 

return true; 
}catch(Exception err){ 
return false; 




//======================================= 
package product; 
import java.sql.*; 
public class catalog 

ConnectDB conn=new ConnectDB(); 
String str=null; 
String sql=null; 
ResultSet rs=null; 
String AncestorID,LinkStr; 

public String getCatalog(){ 

str="<select name="FatherID" class="p9">
"+ 
"<option value="-1" selected>請選擇父類</option>
"; 
String sql=null; 
sql="select * from catalog order by AncestorID,Linkstr"; 
ResultSet rs=conn.execute(sql); 
try{ 
while (rs.next()) { 
str=str+"<option value="+rs.getString("Productid")+">"; 
int nbspCount=rs.getString("LinkStr").length()-1; 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富阳市| 喜德县| 靖安县| 商洛市| 北流市| 都昌县| 山西省| 板桥市| 铜鼓县| 前郭尔| 蒙城县| 高碑店市| 天峻县| 日土县| 山丹县| 四会市| 永定县| 永嘉县| 南溪县| 万载县| 丹寨县| 承德县| 邵阳县| 昌都县| 玉树县| 韩城市| 康保县| 盖州市| 汪清县| 桦南县| 商都县| 玉树县| 阳信县| 辽宁省| 怀宁县| 香格里拉县| 平江县| 石首市| 南阳市| 呈贡县| 常宁市|