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

📄 base.java~2~

📁 对项目
💻 JAVA~2~
字号:
package zhaobiao.db;import java.util.*;import java.sql.*;import zhaobiao.db.*;import zhaobiao.date.*;/** * <p>Title: 招标管理信息系统</p> * <p>Description: 招标管理信息系统的前台设计</p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: 北京王者无敌</p> * @author csk * @version 1.0 */public class Base {  public Base() {  }  /**  根据项目id获得该项目对象   *   *   */  public Project getProject(long project_id)  {    Project pj=new Project();    db=DBConnectionManager.getInstance();    con=db.getConnection("idb");    String sql="select *from project where project_id=?";    try {      ps=con.prepareStatement(sql);      ps.setLong(1,project_id);      rs=ps.executeQuery();      if(rs.next())      {        pj.setProject_id(rs.getLong("project_id"));        pj.setProject_name(rs.getString("project_name"));        pj.setProject_time(rs.getString("project_time"));        pj.setProject_company(rs.getString("project_company"));        pj.setProject_cost(rs.getString("project_cost"));        pj.setProject_content(rs.getString("project_content"));      }    }    catch (SQLException ex) {      freeCon();      ex.printStackTrace();    }    freeCon();    return pj;  }  /**  根据类别的id获得该类别对象   *   *   */  public Type getType(long type_id)  {    Type type=new Type();    db=DBConnectionManager.getInstance();    con=db.getConnection("idb");    String sql="select *from type where type_id=?";    try {      ps=con.prepareStatement(sql);      ps.setLong(1,type_id);      rs=ps.executeQuery();      if(rs.next())      {        type.setType_id(rs.getLong("type_id"));        type.setType_name(rs.getString("type_name"));        type.setType_content(rs.getString("type_content"));      }    }    catch (SQLException ex) {      ex.printStackTrace();      freeCon();    }    freeCon();    return type;  }  /**根据产品id获得该产品对象   *   *   */  public Product getProduct(long product_id)  {    Product pd=new Product();    db=DBConnectionManager.getInstance();    con=db.getConnection("idb");    String sql="select *from product where product_id=?";    try {      ps=con.prepareStatement(sql);      ps.setLong(1,product_id);      rs=ps.executeQuery();      if(rs.next())      {        pd.setProduct_id(rs.getLong("product_id"));        pd.setProduct_name(rs.getString("product_name"));        pd.setType_id(rs.getLong("type_id"));        pd.setProduct_content(rs.getString("product_content"));      }    }    catch (SQLException ex) {      freeCon();      ex.printStackTrace();    }    freeCon();    return pd;  }  /**   * 释放数据库资源<p>   *PreparedStatement和ResultSep将关闭,Connection返回给连接池   * @param      无   * @repurn     无   * @exception  SQLException   *   */  public void freeCon(){    try {      if (rs!=null)        rs.close() ;      if (ps!=null)        ps.close() ;    }    catch (SQLException ex) {    }    if (db!=null)      db.freeConnection("idb",con) ;  }  private DBConnectionManager db;  private Connection con=null;  private ResultSet rs=null;  private PreparedStatement ps=null;}

⌨️ 快捷键说明

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