0

我在tomcat的server.xml中设置了数据源,如下所示

<Context
    docBase="C:/Java_WS/GIT WS/reportingsuite/reporting-api/target/reporting-api-0.0.1-SNAPSHOT"
    path="" reloadable="true">

    <Resource name="jdbc/postgres" 
        auth="Container"  
        provider="mondrian"
        type="javax.sql.DataSource" 
        driverClassName="org.postgresql.Driver"
        jdbcdrivers="mondrian.olap4j.MondrianOlap4jDriver"
        Catalog="C:\Java_WS\GIT WS\reportingsuite\reporting-api\src\main\webapp\WEB-INF\Schema1.xml" 
        url="jdbc:postgresql://localhost:5432/postgres"
        username="postgres" 
        password="password" 
        maxActive="20" 
        maxIdle="10"
        maxWait="-1" 
        accessToUnderlyingConnectionAllowed="true" />
</Context>

使用以下 java 代码获取数据源并尝试创建 olapconnection ..

Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/postgres");
this.connection = ds.getConnection();
this.olapConnection = connection.unwrap(OlapConnection.class);

在最后一行我得到了例外..

org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Connection.unwrap(Class<T>) is not yet implemented

我已经尝试过互联网上提供的各种选项,但它似乎不起作用..有人可以在这里提供帮助。

4

1 回答 1

0

您正在将关系连接展开为 olap 连接。这永远不会奏效。我假设您正在尝试通过 olap4j 使用 Mondrian 并通过 Postgres 的连接来提供它。

我建议你花点时间回到基础。阅读这个olap4j 教程

简而言之,您需要创建一个到 Mondrian 的 JDBC 连接。在创建此连接时,您还将传递参数以指示 Mondrian 如何连接到 Postgres。您将从您身边获得的连接将可解包到 OlapConnection 中。您不直接创建与 Postgres 的连接。蒙德里安会为您解决。

于 2014-06-13T14:26:09.200 回答