/* 	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

  Date date1 = new Date(2014-1900,6-1,25);

  String day1=sdf.format(date1);
  就是这样获取*/
  public ArrayList<purchaseList> findByPurch_dates(String day1, String day2) {

    purchaseList list;
    ArrayList<purchaseList> showList = new ArrayList<purchaseList>();
    try {

      Connection con = initDB();
      // 创建SQL命令对象
      Statement stmt = con.createStatement();
      // 创建SQL命令字符串
      String query =
          "select * from purchaseList where purch_date between'" + day1 + "'and'" + day2 + "'";

      // 执行SQL语句
      ResultSet rs = stmt.executeQuery(query);
      while (rs.next()) {
        list = new purchaseList();
        list.setPurch_id(rs.getString("purch_id"));
        list.setPurch_date(rs.getString("purch_date"));
        list.setPurch_totalPrice(rs.getFloat("purch_totalPrice"));
        list.setUnit_id(rs.getString("unitId"));
        list.setAcc_id(rs.getString("acc_id"));
        showList.add(list);
        list = null;
      }
      // 关闭记录集
      rs.close();
      // 关闭命令对象连接
      stmt.close();

      // 关闭数据库连接
      con.close();

    } catch (SQLException e) {
      System.out.println("查找数据失败!");
      e.printStackTrace();
    }

    return showList;
  }
  public purchaseList findByPurch_id(String purch_id) {
    purch_id.trim();
    purchaseList purh = new purchaseList();

    try {

      Connection con = initDB();
      // 创建SQL命令对象
      Statement stmt = con.createStatement();
      // 创建SQL命令字符串
      String query = "select * from purchaseList where purch_id ='" + purch_id + "'";

      // 执行SQL语句
      ResultSet rs = stmt.executeQuery(query);
      rs.next();
      purh.setPurch_id(rs.getString("purch_id"));
      purh.setPurch_date(rs.getString("purch_date"));
      purh.setPurch_totalPrice(rs.getFloat("purch_totalPrice"));
      purh.setUnit_id(rs.getString("unitId"));
      purh.setAcc_id(rs.getString("acc_id"));

      // 关闭记录集
      rs.close();
      // 关闭命令对象连接
      stmt.close();

      // 关闭数据库连接
      con.close();

    } catch (SQLException e) {
      System.out.println("查找数据失败!");
      e.printStackTrace();
    }

    return purh;
  }