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