?? deletemodel.java
字號:
/*
* DeleteModel.java
*
* Created on 2007年3月20日, 上午8:13
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package News.ProcessData;
import java.sql.*;
import News.Common.DBManager;
/**
*
* @author 吳西博
*/
public class DeleteModel {
private Connection conn=null;
private PreparedStatement ps=null;
/** Creates a new instance of DeleteModel */
public DeleteModel() {
}
public boolean DeleteLink(String IDparam)
{
int i=0,ID=0;
try{
ID=Integer.parseInt(IDparam);
}catch(NumberFormatException e){ID=-1;}
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("delete from Links where ID=?");
ps.setInt(1,ID);
i=ps.executeUpdate();
}catch(SQLException e){System.out.println(e.getMessage());return false;}
finally{
try{
if(ps!=null){ps.close();}
if(conn!=null){conn.close();}
}catch(SQLException e1){System.out.println(e1.getMessage());}
}
if(i>0)
return true;
else return false;
}
public boolean DeleteNotice(String IDparam)
{
int i=0,ID=0;
try{
ID=Integer.parseInt(IDparam);
}catch(NumberFormatException e){ID=-1;}
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("delete from Notice where ID=?");
ps.setInt(1,ID);
i=ps.executeUpdate();
}catch(SQLException e){System.out.println(e.getMessage());return false;}
finally{
try{
if(ps!=null){ps.close();}
if(conn!=null){conn.close();}
}catch(SQLException e1){System.out.println(e1.getMessage());}
}
if(i>0)
return true;
else return false;
}
public boolean DeleteCatalog(String IDparam)
{
int i=0,ID=0;
try{
ID=Integer.parseInt(IDparam);
}catch(NumberFormatException e){ID=-1;}
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("delete from Catalogs where ID=?");
ps.setInt(1,ID);
i=ps.executeUpdate();
}catch(SQLException e){System.out.println(e.getMessage());return false;}
finally{
try{
if(ps!=null){ps.close();}
if(conn!=null){conn.close();}
}catch(SQLException e1){System.out.println(e1.getMessage());}
}
if(i>0)
return true;
else return false;
}
public boolean DeleteNew(String IDparam)
{
int i=0,ID=0;
try{
ID=Integer.parseInt(IDparam);
}catch(NumberFormatException e){ID=-1;}
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("delete from News where ID=?");
ps.setInt(1,ID);
i=ps.executeUpdate();
}catch(SQLException e){System.out.println(e.getMessage());return false;}
finally{
try{
if(ps!=null){ps.close();}
if(conn!=null){conn.close();}
}catch(SQLException e1){System.out.println(e1.getMessage());}
}
if(i>0)
return true;
else return false;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -