首页 >数据库 >mysql教程 >树形结构的实现

树形结构的实现

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-07 15:12:291055浏览

本例采用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