我尝试使用Olap4J连接到OLAP多维数据集。我正在使用jdk14
和olap4j-1.0.0.445.jar
。我知道服务器和目录的IP地址。但我无法连接。以下异常似乎是最大的问题:
Server returned HTTP response code: 401 for URL: http://xx.xx.xx.xxx/olap/msmdpump.dll
我的请求中是否遗漏了某种身份验证信息,或者我错过了一些更基本的信息?
连接:
try {
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
OlapConnection con;
try {
con = (OlapConnection) DriverManager.getConnection("jdbc:xmla:Server=http://xx.xx.xx.xxx/olap/msmdpump.dll;Catalog=xxx");
OlapWrapper wrapper = con;
OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
OlapStatement stmt = olapConnection.createStatement();
olapConnection.setCatalog("Analysis Services Tutorial");
stmt.executeOlapQuery("SELECT {[Customer].[City]} ON Rows FROM [Internet Sales] ");
} catch (SQLException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
例外:
"C:\Program Files\Java\jdk1.8.0_121\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55443,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\name\Documents\project directory\Olap4JTest\target\classes;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\xercesImpl.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\asm.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\asm-commons.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\asm-tree.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\javacup.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-jdk14-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-tck-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\olap4j-xmla-1.0.0.445.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\retroweaver.jar;C:\Users\name\Documents\project directory\Olap4JTest\src\lib\retroweaver-rt.jar;C:\Users\name\.m2\repository\backport-util-concurrent\backport-util-concurrent-java12\3.1\backport-util-concurrent-java12-3.1.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3.4\lib\idea_rt.jar" main.Main
Connected to the target VM, address: '127.0.0.1:55443', transport: 'socket'
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
/C:/Users/name/Documents/project%20directory/Olap4JTest/target/classes/main/static/scene.fxml
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at main.Main.start(Main.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.RuntimeException: org.olap4j.OlapException: This connection encountered an exception while executing a query.
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:75)
at org.olap4j.driver.xmla.DeferredNamedListImpl.size(DeferredNamedListImpl.java:89)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapDatabase(XmlaOlap4jConnection.java:365)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.getOlapCatalogs(XmlaOlap4jConnection.java:441)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.setCatalog(XmlaOlap4jConnection.java:397)
at main.MainController.initialize(MainController.java:30)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 17 more
Caused by: org.olap4j.OlapException: This connection encountered an exception while executing a query.
at org.olap4j.driver.xmla.XmlaHelper.createException(XmlaHelper.java:35)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:735)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.populateList(XmlaOlap4jConnection.java:708)
at org.olap4j.driver.xmla.DeferredNamedListImpl.populateList(DeferredNamedListImpl.java:101)
at org.olap4j.driver.xmla.DeferredNamedListImpl.getList(DeferredNamedListImpl.java:69)
... 23 more
Caused by: org.olap4j.driver.xmla.proxy.XmlaOlap4jProxyException: This proxy encountered an exception while processing the query.
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.getResponse(XmlaOlap4jHttpProxy.java:158)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jAbstractHttpProxy.get(XmlaOlap4jAbstractHttpProxy.java:176)
at org.olap4j.driver.xmla.XmlaOlap4jConnection.executeMetadataRequest(XmlaOlap4jConnection.java:733)
... 26 more
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://10.96.10.243/olap/msmdpump.dll
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at org.olap4j.driver.xmla.proxy.XmlaOlap4jHttpProxy.getResponse(XmlaOlap4jHttpProxy.java:121)
... 28 more
Disconnected from the target VM, address: '127.0.0.1:55443', transport: 'socket'
Exception running application main.Main
Process finished with exit code 1
答案 0 :(得分:1)
我和你的问题一样。我想连接到我的OLAP多维数据集,该多维数据集托管在localhost中。
我注意到当我在浏览器中向http://192.168.0.151/OLAP/msmdpump.dll发送GET请求时,我需要输入用户名和密码。我想可能是我的驱动程序无法访问此资源。啊哈!我是对的;)
所以我想最简单的解决方案如下:尝试设置匿名IIS身份验证。我知道这不是最好的选择,但是当你想要开始使用OLAP时它就可以工作了。
我的工作连接字符串:
Connection connection = DriverManager.getConnection(
"jdbc:xmla: Server=http://192.168.0.151/OLAP/msmdpump.dll;" +
"Data Source=http://192.168.0.151/OLAP/msmdpump.dll;" +
"Initial Catalog=AdventureWorksDW2014; " +
"Integrated Security=Basic; " +
"User ID=XXX; " +
"Password=XXX;");
用户ID - 它是一个db用户名 密码 - 这是db用户名的密码
更多的一点 - 我怀疑你的olap查询它不是一个正确的mdx查询所以你可能会得到OlapException。
祝你好运!