0

I have setup datasource in server.xml in tomcat like below

<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>

Using the following java code to get the datasource and trying to create 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);

At the last line am getting the exception ..

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

I had tried various options available over internet but it does not seem to be working .. can someone please help here.

Ambrish
  • 3,627
  • 2
  • 27
  • 42
  • PgJDBC driver version? – Craig Ringer Jun 12 '14 at 02:53
  • Well, surely if you got an "is not yet implemented" error the first thing you'd do is *check if it's implemented in the latest driver version*, right? You could look at the source code (https://github.com/pgjdbc/pgjdbc) or test with the new driver. – Craig Ringer Jun 12 '14 at 15:10
  • I changed the driver to latest one ... now i am not getting the same error but the following one... java.sql.SQLException: Cannot unwrap to org.olap4j.OlapConnection at org.postgresql.jdbc4.AbstractJdbc4Connection.unwrap(AbstractJdbc4Connection.java:224) at org.postgresql.jdbc4.Jdbc4Connection.unwrap(Jdbc4Connection.java:21) at – user3731509 Jun 12 '14 at 18:46

1 Answers1

0

You are unwrapping the relational connection into an olap connection. This will never work. I'm assuming that you're trying to use Mondrian through olap4j and feed it with a connection from Postgres.

I suggest you take a moment to go back to basics. Read this olap4j tutorial.

In a nutshell, you need to create a JDBC connection to Mondrian. While creating this connection, you will also pass parameters to instruct Mondrian how to connect to Postgres. The connection that you will obtain from your side will be unwrappable into an OlapConnection. You do not create a connection to Postgres directly. Mondrian will take care of it for you.

Luc
  • 672
  • 3
  • 8