新闻发布系统
}else{
return ERROR; } }else{
return ERROR; } }
}catch(Exception e){ e.printStackTrace(); return ERROR; }
return SUCCESS; } }
2、文件信息存入数据库:
public boolean savePath(String filePath,String name,String time) { boolean flag = false;
String sql = "insert into upload values (null,?,?,?)"; try {
con = DBConnector.getConnection(); pstmt = con.prepareStatement(sql); pstmt.setString(1, filePath); pstmt.setString(2, name); pstmt.setString(3, time);
int result = pstmt.executeUpdate(); if(result != 0) { flag = true; }
} catch (SQLException e) { e.printStackTrace(); }finally{
DBConnector.free(rs, pstmt, con); }
return flag; }
3.4.2 删除文件
功能:删除服务器中供下载的文件
实现:删除服务器中供下载的文件,并删除数据库中相应的记录 package com.king.action; import java.io.File;
import org.apache.struts2.ServletActionContext; import org.omg.CORBA.Request;
import com.king.dao.UploadManager;