1
我有一個數據源,它有一個提供程序MSOLAP我想通過基於Java的應用程序連接到此源。我用下面的:使用Java連接MS OLAP
public static void main(String[] args) throws Exception {
// Load the driver
Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
// Connect
final Connection connection =
DriverManager.getConnection(
// This is the SQL Server service end point.
"jdbc:xmla:Server=http://localhost:81/mondrian/xmla"
// Tells the XMLA driver to use a SOAP request cache layer.
// We will use an in-memory static cache.
+ ";Cache=org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache"
// Sets the cache name to use. This allows cross-connection
// cache sharing. Don't give the driver a cache name and it
// disables sharing.
+ ";Cache.Name=MyNiftyConnection"
// Some cache performance tweaks.
// Look at the javadoc for details.
+ ";Cache.Mode=LFU;Cache.Timeout=600;Cache.Size=100",
// XMLA is over HTTP, so BASIC authentication is used.
null,
null);
// We are dealing with an olap connection. we must unwrap it.
final OlapConnection olapConnection = connection.unwrap(OlapConnection.class);
// Check if it's all groovy
ResultSet databases = olapConnection.getMetaData().getDatabases();
databases.first();
System.out.println(
olapConnection.getMetaData().getDriverName()
+ " -> "
+ databases.getString(1));
// Done
connection.close();
}
我得到的類OlapConnection
未編譯。我有兩個問題:1-我使用maven來構建這個測試,但它沒有顯示錯誤,爲什麼不能找到這個類?
2-是否有任何其他方式連接到MSOLAP而不使用olap4j?
我已經試過您指定的例子,但仍maven的依賴性無法提供OlapConnection類。我更新了代碼 –
如果您的問題與Maven有關,那麼這是一個單獨的問題,根本與olap4j無關。我建議確保你包含org.olap4j:olap4j和org.olap4j:olap4j-xmla作爲依賴關係。 – Luc