zoukankan      html  css  js  c++  java
  • 数据库中取多组数据处理

    public class GetCustomerInfo {
    // public static List main(String[] args) throws Exception{
    public List<Map> GetCustomerInfo() throws Exception{
    DBean dbean = null;
    Connection conn = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    StringBuffer sb = new StringBuffer();
    sb.append(" select t.real_name,t.gender,to_char(t.birthday,'yyyymmdd') birthday,t.certi_type,t.certi_code from t_customer t where t.status=1");
    sb.append(" and t.certi_type=1 and length(t.certi_code)=18 and t.certi_code not like '0%' AND t.certi_code not in ('102608235203284158')");
    sb.append(" and (exists (select 1 from t_contract_master t1 where t1.applicant_id=t.customer_id and t1.liability_state=1) or ");
    sb.append(" exists (select 1 from t_contract_product t2 where t2.insured_1=t.customer_id and t2.liability_state=1)) and ROWNUM<5000 ");
    try {
    dbean = new DBean();
    dbean.connect();
    conn = dbean.getConnection();
    pst = conn.prepareStatement(sb.toString());
    rs = pst.executeQuery();
    List<Map> list = new ArrayList();
    ResultSetMetaData md = rs.getMetaData();
    int columnCount = md.getColumnCount();
    while (rs.next()) {
    Map<String, String> rowData = new HashMap<String, String>();
    for (int i = 1; i <= columnCount; i++) {
    rowData.put(md.getColumnName(i), rs.getObject(i).toString());
    }
    list.add(rowData);
    }
    // System.out.println(list.get(1));
    return list;
    // System.out.println(list);
    }catch (Exception e) {
    throw e;
    } finally {
    DBean.clear(rs, pst, conn);
    }
    }
    }

    运用获取的数据:

    GetCustomerInfo a = new GetCustomerInfo();
    List<Map> m = a.GetCustomerInfo();

    i=0

    String iBirthday = m.get(i).get("BIRTHDAY").toString();
    String iCerti_code = m.get(i).get("CERTI_CODE").toString();
    String iReal_name = m.get(i).get("REAL_NAME").toString();
    String iGender = m.get(i).get("GENDER").toString();
    String iCerti_type = m.get(i).get("CERTI_TYPE").toString();

    i++

  • 相关阅读:
    Linux——shell简单学习(一)
    Linux——进程管理简单学习笔记(二)
    Linux——进程管理学习简单笔记
    Linux——用户管理简单学习笔记(四)
    PHP计算程序运行时间的类
    php几个常用的概率算法(抽奖、广告首选)
    限制非安全IP访问
    简单的点击短信发送计时器
    php 以图搜图
    递归获取二维数组后代、删除后代
  • 原文地址:https://www.cnblogs.com/xiaofeng91/p/13891515.html
Copyright © 2011-2022 走看看