製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

Azure Data Lake Storage JDBC Driver

Azure Data Lake Storage データに連携するJava アプリケーションを素早く、簡単に開発できる便利なドライバー。

データ連携でお困りですか?

お問い合わせ

JDBI からAzure Data Lake Storage Data のデータアクセスオブジェクトを作成


JDBI でAzure Data Lake Storage data 用のSQL オブジェクトAPIを作成する方法を概説します。


azuredatalake ロゴ画像
jdbc ロゴ画像

JDBC

JDBI ロゴ画像

JDBI は、Fluent スタイルとSQL オブジェクトスタイルという2つの異なるスタイルAPI を公開する、Java 用のSQL コンビニエンスライブラリです。CData JDBC Driver for ADLS は、Java アプリケーションとリアルタイムAzure Data Lake Storage data のデータ連携を実現します。これらの技術を組み合わせることによって、Azure Data Lake Storage data へのシンプルなコードアクセスが可能になります。ここでは、基本的なDAO(Data Access Object )とそれに付随するAzure Data Lake Storage data の読み書きのためのコードの作成について説明します。

Azure Data Lake Storage Resources Entity のDAO を作成

以下のインターフェースは、実装されるSQL ステートメントごとに単一のメソッドを作成するためのSQL オブジェクトの正しい動作を宣言します。

public interface MyResourcesDAO { //request specific data from Azure Data Lake Storage (String type is used for simplicity) @SqlQuery("SELECT Permission FROM Resources WHERE Type = :type") String findPermissionByType(@Bind("type") String type); /* * close with no args is used to close the connection */ void close(); }

Azure Data Lake Storage への接続を開く

必要な接続プロパティを収集し、Azure Data Lake Storage に接続するための適切なJDBC URL を作成します。

Authenticating to a Gen 1 DataLakeStore Account

Gen 1 uses OAuth 2.0 in Azure AD for authentication.

For this, an Active Directory web application is required. You can create one as follows:

  1. Sign in to your Azure Account through the .
  2. Select "Azure Active Directory".
  3. Select "App registrations".
  4. Select "New application registration".
  5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
  6. Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
  7. Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.

To authenticate against a Gen 1 DataLakeStore account, the following properties are required:

  • Schema: Set this to ADLSGen1.
  • Account: Set this to the name of the account.
  • OAuthClientId: Set this to the application Id of the app you created.
  • OAuthClientSecret: Set this to the key generated for the app you created.
  • TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
  • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

Authenticating to a Gen 2 DataLakeStore Account

To authenticate against a Gen 2 DataLakeStore account, the following properties are required:

  • Schema: Set this to ADLSGen2.
  • Account: Set this to the name of the account.
  • FileSystem: Set this to the file system which will be used for this account.
  • AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
  • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

ビルトイン接続文字列デザイナー

JDBC URL の構成については、Azure Data Lake Storage JDBC Driver に組み込まれている接続文字列デザイナーを使用してください。JAR ファイルのダブルクリック、またはコマンドラインからJAR ファイルを実行します。

java -jar cdata.jdbc.adls.jar

接続プロパティを入力し、接続文字列をクリップボードにコピーします。

Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

Azure Data Lake Storage の接続文字列は、通常次のようになります。

jdbc:adls:Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;InitiateOAuth=GETANDREFRESH

構成済みのJDBC URL を使用して、DAO インターフェースのインスタンスを取得します。以下に示す特定のメソッドはインスタンスにバインドされたハンドルを開くため、ハンドルとバインドされたJDBC 接続を開放するには、インスタンスを明示的に閉じる必要があります。

DBI dbi = new DBI("jdbc:adls:Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;InitiateOAuth=GETANDREFRESH"); MyResourcesDAO dao = dbi.open(MyResourcesDAO.class); //do stuff with the DAO dao.close();

Azure Data Lake Storage Data について

Azure Data Lake Storage への接続を開いた状態で以前定義したメソッドを呼び出すだけで、Azure Data Lake Storage のResources エンティティからデータを取得できます。

//disply the result of our 'find' method String permission = dao.findPermissionByType("FILE"); System.out.println(permission);

JDBI ライブラリはJDBC 接続を処理できるため、CData JDBC Driver for ADLS と統合することで、SQL Object API for ADLS を簡単に作成できます。今すぐ無料トライアルをダウンロードし、Java アプリケーションでライブAzure Data Lake Storage を操作しましょう。