public List executeCallableStatement(CallableStatement colStmt) {
ResultSet res = null;
List result = null;
List multiResult = new ArrayList();
int count = 1;
try {
colStmt.execute();
while (true) {
res = colStmt.getResultSet();
if (res != null){
result = generateResultList(res);
count ++;
}
if(count > 1){
multiResult.add(result);
}
// Advance and quit if done
if ((colStmt.getMoreResults() == false)
&& (colStmt.getUpdateCount() == -1))
{
if (count == 2)
{
multiResult = result;
}
break;
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return multiResult;
}
/**
* Genarates ArrayList for given result set.
* @param res
* @return
*/
private List generateResultList(ResultSet res){
Hashtable hashTab = null;
List resultList = new ArrayList();
try {
if (res != null) {
ResultSetMetaData rsm = res.getMetaData();
int columnCount = rsm.getColumnCount();
while (res.next()) {
hashTab = new Hashtable();
for (int i = 1; i <= columnCount; i++) {
String columnName = rsm.getColumnName(i);
if (rsm.getColumnType(i) == Types.VARCHAR)
hashTab.put(columnName, res.getString(columnName));
else if (rsm.getColumnType(i) == Types.INTEGER)
hashTab.put(columnName, new Integer(res
.getInt(columnName)));
else if (rsm.getColumnType(i) == Types.TIMESTAMP)
hashTab.put(columnName, res
.getTimestamp(columnName));
else if (rsm.getColumnType(i) == Types.DECIMAL)
hashTab.put(columnName, new Float(res
.getFloat(columnName)));
}
resultList.add(hashTab);
}
}else{
return null;
}
} catch (SQLException e) {
e.printStackTrace();
}
return resultList;
}