{
Vector pclass = new Vector();
嘗試
{
stmt = con . create statement();
string SQL = " select * from parentid = 0的模塊";
RS = stmt . execute query(SQL);
模塊cvo = null
while(rs.next())
{
cvo =新模塊();
cvo . setmodule _ id(RS . getint(" Module _ id "));
cvo . setmodule _ name(RS . getstring(" Module _ name "));
cvo . setmodule _ URL(RS . getstring(" Module _ URL "));
cvo . setparentid(RS . getint(" parentid "));cvo . setrootid(RS . getint(" rootid "));cvo . set depth(RS . getint(" depth "));pclass . add(cvo);
}
for(int I = 0;我& ltpclass . size();i++)
{
Module pcvo =(Module)pclass . get(I);
show tree menu(pcvo);
}
con . commit();} catch (SQLException e)
{
e . printstacktrace();
}最後
{
嘗試
{
如果(rs!=空)
{
RS . close();
}
如果(stmt!=空)
{
stmt . close();
}
如果(con!=空)
{
con . close();
}
}
catch (SQLException e)
{
e . printstacktrace();
}
}
返回classList
}
公共void ShowTreeMenu(模塊c)
{
模塊ccvo = null
string SQL = " select * from Module where parentid = "+c . get Module _ id();
Vector cclass = new Vector();
嘗試
{
模塊cvotemp
stmt = con . create statement();
RS = stmt . execute query(SQL);
while(rs.next())
{
cvo temp = new Module();
cvo temp . setmodule _ id(RS . getint(" Module _ id "));
cvo temp . set Module _ name(RS . getstring(" Module _ name "));
cvo temp . setmodule _ URL(RS . getstring(" Module _ URL "));
cvo temp . setparentid(RS . getint(" parentid "));cvo temp . setrootid(RS . getint(" rootid "));cvo temp . set depth(RS . getint(" depth "));cclass . add(cvo temp);
}
system . out . println(cclass . size()+"(((((((((((((((((9)));
if(cclass . size()& gt;0)
{
c . sethaschild(" have ");
class list . add(c);
for(int j = 0;j & ltcclass . size();j++)
{
ccvo =(Module)cclass . get(j);
show tree menu(ccvo);
} }否則
{
class list . add(c);
}
} catch (SQLException e)
{
e . printstacktrace();
}
}