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++

  • 相关阅读:
    【网络攻击】之防止短信验证码接口被攻击
    【支付专区】之检查微信预下单返回结果
    【mybatis】之批量添加
    【java】之转码
    【springmvc】之常用的注解
    数字信号处理MATLAB简单序列
    matlab中同一文件定义子函数的方法
    MATLAB 单变量函数一阶及N阶求导
    Android 学习笔记1
    java socket tcp(服务器循环检测)
  • 原文地址:https://www.cnblogs.com/xiaofeng91/p/13891515.html
Copyright © 2011-2022 走看看