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