?? mddclass.java
字號:
package com.v246;
public class MDDClass
{
protected static java.sql.Statement stm=null;
public static void deleteClass(String id)throws Exception
{
java.sql.Connection conn=null;
String rows[][]=null;
AquGetRows getRows=new AquGetRows();
Connections connTmp=new Connections();
try
{
conn=connTmp.getConnection();
stm=conn.createStatement();
}
catch(Exception e)
{
throw new Exception("Error in MDDClass.java NO.1 "+e.getStackTrace());
}
try
{
rows=getRows.getRows(connTmp.getConnection(),"class");
startDelete(rows,id);
}
catch(Exception e)
{
throw new Exception("Error in MDDClass.java NO.2 "+e.getMessage());
}
finally
{
if(stm!=null)stm.close();
if(conn!=null)conn.close();
}
}
public static void startDelete(String rows[][],String id)throws Exception
{
StringBuffer okPath=null;
Path path=new Path();
FileManage fileManage=new FileManage();
FullClassDir fullClass=new FullClassDir();
try
{
String tmpPath=path.getPathFromClass(Path.class);//得么Path.class的絕對路徑
okPath=new StringBuffer(tmpPath);
okPath.replace(tmpPath.indexOf("\\WEB-INF\\classes"),tmpPath.length(),"");//得到虛擬空間上的網站路徑
fileManage.deleteFile(okPath.toString()+"\\Article"+fullClass.getClassDir(Integer.parseInt(id)));
stm.executeUpdate("delete from class where Id="+id);//刪除欄目
stm.executeUpdate("delete from article where ClassId="+id);//刪除該欄目下面的所有文章
}
catch(Exception e)
{
throw new Exception("Error in MDDClass.java NO.3 "+e.getMessage());
}
for(int i=0;i<rows[0].length;i++) //以數據總數為循環條件
{
if(rows[0][i].equals(id))//如果該ID與傳進來的ID穩和,那么
{
if(rows[4][i].equals("true"))//如果該欄目還有子欄目的話
{
for(int j=0;j<rows[0].length;j++)//以數據總數為循還條件,該欄目的所有子欄目
{
if(rows[1][j].equals(rows[0][i]))//如果當前欄目正好是該欄目的子欄目的話
{
startDelete(rows,rows[0][j]);//調用自己進行遞歸
}
}
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -