JDBC Driver for Microsoft SharePoint Excel

Build 23.0.8839

Code からの接続

このセクションでは、JDBC DriverManager またはMicrosoft SharePoint ExcelDataSource インターフェースに接続する方法について説明します。

DriverManager で接続

DriverManager クラスを使用して接続する場合、CData JDBC Driver for Microsoft SharePoint Excel はJDBC 規則に従います。最初にMicrosoft SharePoint Excel ドライバークラスをロードします。次に、接続を作成します。

ドライバーのロード

JDBC 4.0仕様では、次の手順はオプションです。
Class.forName("cdata.jdbc.excelservices.Microsoft SharePoint ExcelDriver");

接続の確立

静的なDriverManager クラスのgetConnection メソッドで接続文字列を指定します。接続文字列を"jdbc:excelservices:" で始めます。一般的な接続文字列は以下のとおりです。

Connection conn = DriverManager.getConnection("jdbc:excelservices:Url=https://myorg.sharepoint.com;User=admin@myorg.onmicrosoft.com;Password=password;File=Book1.xlsx;");
または、Properties オブジェクトを使用して接続オプションを準備できます。Properties オブジェクトをDriverManager に渡します。
Properties prop = new Properties();
prop.setProperty("Url","https://myorg.sharepoint.com");
prop.setProperty("User","admin@myorg.onmicrosoft.com");
prop.setProperty("Password","password");
prop.setProperty("File","Book1.xlsx");

Connection conn = DriverManager.getConnection("jdbc:excelservices:",prop);

Microsoft SharePoint ExcelDataSource クラスで接続

以下の例に示すように、Microsoft SharePoint ExcelDataSource クラスを使用してプールされた接続を作成できます。詳しくは、接続プール を参照してください。

次の例は、プールされたConnection オブジェクトをインスタンス化します。

Microsoft SharePoint ExcelDataSource ds = new Microsoft SharePoint ExcelDataSource("jdbc:excelservices:UseConnectionPooling=true;Url=https://myorg.sharepoint.com;User=admin@myorg.onmicrosoft.com;Password=password;File=Book1.xlsx;"); 
Connection conn = ds.getConnection();

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839