processorsdao.java~40~

来自「些程序用java实现一个装机程序,不过是一个C/S架构,但是在数据库的设计方面与」· JAVA~40~ 代码 · 共 96 行

JAVA~40~
96
字号
package pcdiysystem.Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Vector;
import pcdiysystem.Beans.ProcessorsBean;
/**
 * <p>Title: 自助装机系统</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author kamiiiyu
 * @version 1.0
 */
public class ProcessorsDAO {

  public ProcessorsDAO() {
  }

  public ArrayList getProcessorsListByManufacturer(String manufacturer){
    ArrayList list=new ArrayList();
    Connection dbConnection=null;
    PreparedStatement pStatement=null;
    ResultSet resultSet=null;
    try {
      dbConnection = ConnectionManager.getConnection();
      if(dbConnection!=null)
        System.out.println("OK!");
      String proList = "select p.* from processors as p left outer join Manufacturersofprocessor as ma on ma.Manufacturerid=p.manufacturerid where ma.manufacturer=?";
      pStatement = dbConnection.prepareStatement(proList);
      pStatement.setString(1, manufacturer);
      resultSet=pStatement.executeQuery();
      while(resultSet.next()){
        ProcessorsBean pb=new ProcessorsBean();
        pb.setManufacturerId(resultSet.getString(2));
        pb.setType(resultSet.getString(3));
        pb.setClockSpeed(resultSet.getString(4));
        pb.setFsbs(resultSet.getString(5));
        pb.setSocket(resultSet.getString(6));
        pb.setPrice(resultSet.getString(7));
        pb.setSocket(resultSet.getString(8));
        pb.setDescription(resultSet.getString(9));
        list.add(pb);
      }
    }
    catch (SQLException ex) {
    }finally{
      ConnectionManager.closeResultSet(resultSet);
      ConnectionManager.closeStatement(pStatement);
      ConnectionManager.closeConnection(dbConnection);
    }
    return list;
  }

  public Vector getBaseInfomation(String manufacturer){
    Vector list=new Vector();
    Connection dbConnection=null;
    PreparedStatement pStatement=null;
    ResultSet resultSet=null;
    try {
      dbConnection = ConnectionManager.getConnection();
      if(dbConnection!=null)
        System.out.println("OK!");
      String proList = "select p.* from processors as p left outer join Manufacturersofprocessor as ma on ma.Manufacturerid=p.manufacturerid where ma.manufacturer=?";
      pStatement = dbConnection.prepareStatement(proList);
      pStatement.setString(1, manufacturer);
      resultSet=pStatement.executeQuery();
      while(resultSet.next()){
        Vector temp=new Vector();

        System.out.println("test");

        temp.add(resultSet.getString(3));
        temp.add(resultSet.getString(7));
        temp.add(resultSet.getString(9));
        list.add(temp);
      }
}
catch (SQLException ex) {
}finally{
  ConnectionManager.closeResultSet(resultSet);
  ConnectionManager.closeStatement(pStatement);
  ConnectionManager.closeConnection(dbConnection);
}
return list;

  }
}

⌨️ 快捷键说明

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