?? updatemodel.java
字號:
/*
* AddModel.java
*
* Created on 2007年3月17日, 下午12:17
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package News.ProcessData;
import News.Struts.ActionForm.SiteSettingActionForm;
import java.net.URL;
import java.net.URLClassLoader;
import java.sql.*;
import News.Common.DBManager;
/**
*
* @author 吳西博
*/
public class UpdateModel {
private Connection conn=null;
private PreparedStatement ps=null;
/** Creates a new instance of AddModel */
public UpdateModel() {
}
public boolean UpdateLink(String Name,String URL,String Logo,int IDparam)
{
int i=0,ID=0;
ID=IDparam;
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("update Links set Name=?,URL=?,Logo=? where ID=?");
ps.setString(1,Name);
ps.setString(2,URL);
ps.setString(3,Logo);
ps.setInt(4,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 UpdateNotice(String content,int IDparam)
{
int i=0,ID=0;
ID=IDparam;
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("update Notice set Message=? where ID=?");
ps.setString(1,content);
ps.setInt(2,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 UpdateCatalog(String catalogName,String logoURL,int IDparam)
{
int i=0,ID=0;
ID=IDparam;
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("update Catalogs set Title=?,LogoURL=? where ID=?");
ps.setString(1,catalogName);
ps.setString(2,logoURL);
ps.setInt(3,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 UpdateNews(String author,String title,String content,int IDparam)
{
int i=0,ID=0;
ID=IDparam;
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("Update News set Author=?,Title=?,Content=? where ID=?");
ps.setString(1,author);
ps.setString(2,title);
ps.setString(3,content);
ps.setInt(4,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 UpdateSiteSetting(SiteSettingActionForm data)
{
int i=0;
try{
conn=DBManager.getConnection();
ps=conn.prepareStatement("update SiteSetting set SiteName=?,SiteURL=?,MetaDescription=?,MetaKeywords=?,CompanyName=?,CompanyURL=?,BottomAD=?,TopBanner=?,IsCheckCode=? where ID=1");
ps.setString(1,data.getSiteName());
ps.setString(2,data.getSiteURL());
ps.setString(3,data.getMetaDescription());
ps.setString(4,data.getMetaKeywords());
ps.setString(5,data.getCompanyName());
ps.setString(6,data.getCompanyURL());
ps.setString(7,data.getBottomAD());
ps.setString(8,data.getTopBanner());
ps.setString(9,data.getIsCheckCode());
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 static void main(String arg[])
{
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -