//初始化结果集
private void initResultSet(String dsList, Properties props) throws SQLException {
//获取数据库配置
final String url = props.getProperty("URL");
final String user = props.getProperty("USER");
final String passwd = props.getProperty("PASSWD");
if(url==null || user==null || passwd==null) {
return;
}
//判断Oracle驱动是否存在
if(FooDb.getInstance().isFoundOracleDriver()==false) {
return;
}
Connection conn = FooDb.getInstance().getConnector(url, user, passwd);
Statement stat = FooDb.getInstance().getQueryStat(conn);
//分割所有数据源
final String[] dss = dsList.split(",");
//遍历所有数据源
for(int i = 0; i < dss.length; ++i) {
String sql = props.getProperty(dss[i]);
ResultSet rs = FooDb.getInstance().execQuery(stat, sql);
int colsCount = FooDb.getInstance().getColsCount(rs);
//定义单数据源的记录行
ArrayList<ArrayList<String>> rows = new ArrayList<ArrayList<String>>();
//表头各列
/*
ArrayList<String> header = new ArrayList<String>();
for(int i = 1; i <= colsCount; ++i) {
header.add(FooDb.getInstance().getColName(rs, i));
}
rows.add(header);
*/
//遍历各行
while(rs.next()) {
ArrayList<String> row = new ArrayList<String>();
for(int j = 1; j <= colsCount; ++j) {
row.add(rs.getString(j));
}
rows.add(row);
}
FooDb.getInstance().closeRs(rs);
//将单个结果集存入到结果集容器
this.mResuleSet.put(dss[i], rows);
}
//关闭语句对象和数据库连接
FooDb.getInstance().closeStat(stat);
FooDb.getInstance().closeConn(conn);
} |