⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filebean.java

📁 教师办公管理系统
💻 JAVA
字号:
package to.model.File;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;
import to.model.DBConnection;

public class FileBean 
{
  Connection con=null;
  PreparedStatement ps=null;
  ResultSet rs=null;
  DBConnection db=new DBConnection("CollegePool",500);
  
  
  public String insertFile(fileItem fi)
  {
    try
    {
      con=db.getConnection();
      ps=con.prepareStatement("insert into kjc_file values(?,?,?,?,?)");
      ps.setString(1,fi.getWName());
      ps.setString(2,fi.getWExt());
      ps.setString(3,fi.getWSize());
      ps.setString(4,fi.getWpathName());
      ps.setString(5,fi.getWAddr());
      ps.executeUpdate();
      return "上传成功";
    }//end block try
    catch(Exception e)
    {
      e.printStackTrace();
      return "上传失败";
    }//end block catch
  }//end method insertFile
  public Collection getFile()
  {
     try
      {
        Vector v=new Vector();
        con=db.getConnection();
        ps=con.prepareStatement("select * from kjc_file");
        rs=ps.executeQuery();
        while(rs.next())
        {
          fileItem fi=new fileItem();
          fi.setWName(rs.getString("WName"));
          fi.setWExt(rs.getString("WExt"));
          fi.setWSize(rs.getString("WSize"));
          fi.setWpathName(rs.getString("WPathName"));
          fi.setWAddr(rs.getString("WAddr"));
          v.add(fi);
        }//end block while
        return v;
      }//end block try
      catch(Exception e)
      {
        e.printStackTrace();
        return null;
      }//end block catch
  }//end method getFile
  
  
}//end class fileBean

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -