I am trying to get all the data from an MDX
request. For example, I want to foreach
every row in the result. I have the following code:
String cnxURL =
"Jdbc=jdbc:" +
"postgresql://localhost/foodmart;" +
"JdbcDrivers=org.postgresql.Driver;" +
"JdbcUser=postgres;" +
"JdbcPassword=postgres;" +
"Catalog=file:../queries/FoodMart.xml;";
Connection connection = DriverManager.getConnection(cnxURL, null);
String query = "Select ...";
Query q = connection.parseQuery(query);
Result result = connection.execute(q);
I tried result.getCell(new int[]{0,0})
, but I don't know how many rows and what dimension my result has. I also tried to use PrintWriter
like:
File f = new File("output");
try {
PrintWriter pw = new PrintWriter(f);
result.print(pw);
}
catch (FileNotFoundException e) {}
but only one query out of ten got printed.
What am i doing wrong here? How can get this working?
There is a code sample here: Presentation of data from Mondrian OLAP engine + Olap4j. And there is another one at http://www.docjar.com/html/api/org/olap4j/sample/SimpleQuerySample.java.html.