> 데이터 베이스 > MySQL 튜토리얼 > 树形结构的实现

树形结构的实现

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-06-07 15:12:29
원래의
1059명이 탐색했습니다.

本例采用access做为实例,所有还有很多要改进的地方。 请读者自已改进 packagePRodUCt; importjava.sql.*; publicclassConnectDB{ StringstrDBDriver=sun.jdbc.odbc.JdbcOdbcDriver; StringstrConnstr=jdbc:odbc:product; Connectionconn=null; ResultSetrs=


本例采用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="
관련 라벨:
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿