use of org.mifos.reports.business.ReportsParamQuery in project head by mifos.
the class ReportsParamQueryDAO method listValuesOfParameters.
/**
* This method lists all the values of parameter
*/
public List listValuesOfParameters(ReportsParams rps) throws Exception {
List<ReportsParamQuery> alValues = new ArrayList();
ReportsDataSource rds = rps.getReportsDataSource();
Connection con = null;
try {
String driver = rds.getDriver();
String url = rds.getUrl();
String username = rds.getUsername();
String password = rds.getPassword();
if (driver != null && !driver.equals("")) {
Class.forName(driver);
con = DriverManager.getConnection(url, username, password);
Statement stm = con.createStatement();
String data = rps.getData();
if (data != null && !data.equals("")) {
ResultSet rs = stm.executeQuery(data);
ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) {
ReportsParamQuery obj = new ReportsParamQuery();
if (rsmd.getColumnCount() >= 2) {
obj.setValue1(rs.getString(1));
obj.setValue2(rs.getString(2));
} else if (rsmd.getColumnCount() == 1) {
obj.setValue1(rs.getString(1));
obj.setValue2(rs.getString(1));
}
alValues.add(obj);
}
}
}
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return alValues;
}
Aggregations