📄 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 + -