Esempio n. 1
0
  public void UpdateCustomer(CustomerDTO customer)
      throws ClassNotFoundException, SQLException, Exception {
    String sql = "";
    Connection conn = null;
    PreparedStatement stm = null;

    try {
      conn = getConnection();
      String stuempid = customer.getStuemp_no();
      sql =
          "update ykt_cur.t_cif_customer set password='******' where stuemp_no='"
              + stuempid
              + "'";
      stm = conn.prepareStatement(sql);
      stm.executeUpdate();
    } catch (SQLException e) {
      logger.error("²éѯÊý¾Ý¿âʧ°Ü");
      throw (e);
    } catch (Exception e) {
      e.printStackTrace();
      throw (e);
    } finally {
      if (stm != null) {
        stm.close();
      }
    }
  }
Esempio n. 2
0
  public CustomerDTO getCustomerByCustId(String custId) throws Exception {

    String sql = "";
    Connection conn = null;
    PreparedStatement stm = null;
    ResultSet result;
    CustomerDTO temp = new CustomerDTO();
    try {
      conn = getConnection();
      sql = "select * from ykt_cur.t_cif_customer cus " + "where cus.Cut_id=" + custId;
      stm = conn.prepareStatement(sql);
      result = stm.executeQuery();

      while (result.next()) {

        temp.setAddress(result.getString("Address"));
        temp.setArea(result.getInt("Area"));
        temp.setCan_time(result.getString("Can_time"));
        temp.setClassdept_name(result.getString("Classdept_name"));
        temp.setClassdept_no(result.getString("Classdept_no"));
        temp.setComments(result.getString("Comments"));
        temp.setCut_id(result.getInt("Cut_id"));
        temp.setCut_name(result.getString("Cut_name"));
        temp.setCut_state(result.getInt("Cut_state"));
        temp.setCut_type(result.getInt("Cut_type"));
        temp.setMan(result.getString("Man"));
        temp.setMan_id(result.getString("Man_id"));
        temp.setNation(result.getInt("Nation"));
        temp.setPassword(result.getString("Password"));
        temp.setReg_time(result.getString("Reg_time"));
        temp.setSex(result.getString("Sex"));
        temp.setStuemp_no(result.getString("Stuemp_no"));
        temp.setTel(result.getString("Tel"));
        break;
      }
      return temp;

    } catch (Exception e) {
      logger.error("²éѯÊý¾Ý¿âʧ°Ü");
      throw (e);
    } finally {
      if (stm != null) {
        stm.close();
      }
    }
  }
Esempio n. 3
0
 public ArrayList RetriveCustomer(String sql)
     throws ClassNotFoundException, SQLException, Exception {
   Connection conn = null;
   PreparedStatement stm = null;
   ArrayList customers = null;
   try {
     ResultSet result;
     customers = new ArrayList();
     conn = getConnection();
     stm = conn.prepareStatement(sql);
     result = stm.executeQuery();
     while (result.next()) {
       CustomerDTO temp = new CustomerDTO();
       temp.setAddress(result.getString("Address"));
       temp.setArea(result.getInt("Area"));
       temp.setCan_time(result.getString("Can_time"));
       temp.setClassdept_name(result.getString("Classdept_name"));
       temp.setClassdept_no(result.getString("Classdept_no"));
       temp.setComments(result.getString("Comments"));
       temp.setCut_id(result.getInt("Cut_id"));
       temp.setCut_name(result.getString("Cut_name"));
       temp.setCut_state(result.getInt("Cut_state"));
       temp.setCut_type(result.getInt("Cut_type"));
       temp.setMan(result.getString("Man"));
       temp.setMan_id(result.getString("Man_id"));
       temp.setNation(result.getInt("Nation"));
       temp.setPassword(result.getString("Password"));
       temp.setReg_time(result.getString("Reg_time"));
       temp.setSex(result.getString("Sex"));
       temp.setStuemp_no(result.getString("Stuemp_no"));
       temp.setTel(result.getString("Tel"));
       customers.add(temp);
     }
     return customers;
   } catch (SQLException e) {
     logger.error("²éѯ¿Í»§ÐÅϢʧ°Ü");
     throw (e);
   } catch (Exception e) {
     e.printStackTrace();
     throw (e);
   } finally {
     if (stm != null) {
       stm.close();
     }
   }
 }