代码之家  ›  专栏  ›  技术社区  ›  Martin Erlic

无法通过Olap4J API连接到OLAP多维数据集

  •  0
  • Martin Erlic  · 技术社区  · 7 年前

    我正在尝试使用Olap4J连接到OLAP多维数据集。我正在使用 jdk14 olap4j-1.0.0.445.jar

    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
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Aleksandra    7 年前

    我和你有同样的问题。我想连接到我的OLAP多维数据集,它托管在localhost中。

    http://192.168.0.151/OLAP/msmdpump.dll 在我的浏览器中,我需要输入用户名和密码。我想我的司机可能没有访问这个资源的权限。啊哈!我是对的;)

    所以我想最简单的解决方案如下:尝试设置匿名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用户名

    祝你好运