Я пытаюсь подключиться к веб-сервису XMLA через Java API (olap4j) для выполнения запросов MDX по кубу Мондриана, который находится в инструменте BI, размещенном на localhost.
Это мой код ниже:
try {
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
Connection connection =
DriverManager.getConnection(
"jdbc:xmla:Server=http://127.0.0.1:8080/jasperserver-pro/xmla");
OlapWrapper wrapper = (OlapWrapper) connection;
OlapConnection olapConnection = wrapper
.unwrap(OlapConnection.class);
OlapStatement statement = (OlapStatement) connection
.createStatement();
CellSet cellSet =
statement.executeOlapQuery("select [Measures].Members ON COLUMNS\n" +
"from [FAIS_MED]\n");
for (Position row : cellSet.getAxes().get(1)) {
for (Position column : cellSet.getAxes().get(0)) {
for (Member member : row.getMembers()) {
System.out.println(member.getUniqueName());
}
for (Member member : column.getMembers()) {
System.out.println(member.getUniqueName());
}
final Cell cell = cellSet.getCell(column, row);
System.out.println(cell.getFormattedValue());
System.out.println();
}
}
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
Я получу эту ошибку ниже:
java.lang.ClassNotFoundException: org.olap4j.driver.xmla.XmlaOlap4jDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.slimani.bi_restful.testing.MondrianOlap4jDriver.getConnection(MondrianOlap4jDriver.java:18)
at com.slimani.bi_restful.testing.MondrianOlap4jDriver.main(MondrianOlap4jDriver.java:45)
Exception in thread "main" java.lang.NullPointerException at com.slimani.bi_restful.testing.MondrianOlap4jDriver.main(MondrianOlap4jDriver.java:48)