English 中文(简体)
从一个org.h2.jdbc.jdbc.Jdbcconnection 获得一个 olap4j. OlapConcommunction 从一个 org.h2.jdbc.jdbc.Jdbcconnection 获得一个 olp4j. OlapCunction 连接
原标题:Get a olap4j.OlapConnection from a org.h2.jdbc.JdbcConnection

是否有办法从 org.h2.jdbc.Jdbconnection 获得 olap4j.OlapConnection ?

http://www.olap4j.org/olap4j_fs.html#Connections" rel="no follow"> there:

Class.forName("org.h2.Driver");
Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test;", "sa", "");
OlapWrapper wrapper = (OlapWrapper) conn;
OlapConnection olapConn = wrapper.unwrap(OlapConnection.class);

但我得到一个

Exception in thread "main" java.lang.ClassCastException: org.h2.jdbc.JdbcConnection cannot be cast to org.olap4j.OlapWrapper at myprogram.main(Mondrian2H2Test.java:67)

:67 是 OlapWrapper 包装器= (OlapWrapper) conn;

<强 > EDIT:

我也尝试过这个:

Class.forName("org.h2.Driver");
Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test;", "sa", "");
OlapConnection olapConn = conn.unwrap(OlapConnection.class);

因此:

Exception in thread "main" java.lang.AbstractMethodError: org.h2.jdbc.JdbcConnection.unwrap(Ljava/lang/Class;)Ljava/lang/Object; at myprogram.main(Mondrian2H2Test.java:46)

:46 是 OlapConn = conn.unlop (OlapCunction. classle);

最佳回答

http://mondrian.pentaho.com/api/mondrian/olap4j/MondrianOlap4jDriver.html" rel=“nofollow” >MondrianOlap4jDriver javadocs ,在电子邮件列表上,该代码似乎是:

import java.sql.Connection;
import java.sql.DriverManager;
import org.olap4j.OlapConnection;

Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
Connection conn = DriverManager.getConnection(
    "jdbc:mondrian:" + 
    "Jdbc=jdbc:h2:~/test; " +
    "JdbcUser=sa; " +
    "JdbcPassword=; " +
    "Catalog=file:/mondrian/demo/FoodMart.xml; " +
    "JdbcDrivers=org.h2.Driver");
OlapConnection olapConn = conn.unwrap(OlapConnection.class);
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...