我不知道如何使用 Olap4j/Olap 连接生成或创建 Cube,当我有 Cube 时,我可以加载它并使用它,但是我有数据库,我想从代码生成 Cube 并将其保存为 xml。那么我们有多少种方法呢?
Connection connection = DriverManager.getConnection(
String.format(
"jdbc:mondrian:Jdbc=%s; Catalog=file:%s",
"jdbc:mysql://localhost:3306/network?user=root&password=root",
"C:\\Users\\John\\Documents\\pivot4j-web\\src\\java\\org\\pivot4j\\analytics\\test\\FoodMartX.xml"
)
);
OlapConnection olapConnection = connection.unwrap(OlapConnection.class);
Schema s = olapConnection.getOlapSchema();
System.out.println("Schema: " + s.getName());
for (Cube cube : s.getCubes()) {
System.out.println("Cube: " + cube.getName());
for (Dimension dimension : cube.getDimensions()) {
System.out.println("Dimension: " + dimension.getName());
}
for (Measure measure : cube.getMeasures()) {
System.out.println("Measure: " + measure.getName());
}
}