天天看点

Java对oracle查询多个结果集集合的存储

package cn.linkey.rulelib.S029;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.util.*;

 import cn.linkey.dao.*;
 import cn.linkey.factory.*;
 import cn.linkey.rule.LinkeyRule;
 public class d implements LinkeyRule{
@Override
public String run(HashMap<String, Object> params) throws Exception  {
   String sql = "select * from oa_schedule";
   List<Map<String,String>> list = new ArrayList<Map<String,String>>();
   Map<String,String> map = new HashMap<String,String>();
   Connection conn=null;
   ResultSet resultSet=null;
   //title schedule_id
   try {
       conn=Rdb.getNewConnection("lyoa-pool-db");
        resultSet = Rdb.getResultSet(conn,sql);
        while(resultSet.next()) {
          map = new HashMap<String,String>(); 
          map.put("schedule_id",resultSet.getString("schedule_id"));
          map.put("title", resultSet.getString("title"));
      list.add(map);
        }
        for (int i = 0; i < list.size(); i++) {
            BeanCtx.out(list.get(i).get("schedule_id"));
            BeanCtx.out(list.get(i).get("title"));
        }
         
           }catch(Exception e) {
       BeanCtx.p(e.getMessage());
   }finally {
       resultSet.close();
       conn.close();
   }
   return "";
}
 }