製品をチェック

無償トライアル:

無償トライアルへ

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

Azure Data Lake Storage JDBC Driver

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

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

お問い合わせ

JRuby からAzure Data Lake Storage にデータ連携


リアルタイムAzure Data Lake Storage に連携するシンプルなJRuby アプリケーションを作成します。


azuredatalake ロゴ画像
jdbc ロゴ画像

JDBC

JRuby ロゴ画像

JRuby はRuby プログラミング言語の高性能で安定した、完全にスレッド化されたJava 実装です。CData JDBC Driver for ADLS を使用すると、JRuby からリアルタイムAzure Data Lake Storage へのデータ連携を簡単に実装できます。ここでは、Azure Data Lake Storage に接続し、クエリを実行して結果を表示する簡単なJRuby アプリを作成する方法を説明します。

Azure Data Lake Storage データにJDBC で接続

アプリを作成する前に、JDBC Driver のJAR ファイルのインストール場所をメモします。 (通常はC:\Program Files\CDatat\CData JDBC Driver for ADLS\libにあります。)

JRuby は、JDBC をネイティブにサポートしているため、簡単にAzure Data Lake Storage に接続してSQL クエリを実行できます。java.sql.DriverManager クラスのgetConnection 関数を使用してJDBC 接続を初期化します。

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 接続文字列です。

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

Azure Data Lake Storage データへの接続性を持つJRuby アプリを作成

新しいRuby ファイル(例: ADLSSelect.rb) を作成してテキストエディタで開き、次のコードをファイルにコピーします。

require 'java' require 'rubygems' require 'C:/Program Files/CData/CData JDBC Driver for ADLS 2018/lib/cdata.jdbc.adls.jar' url = "jdbc:adls:Schema=ADLSGen2;Account=myAccount;FileSystem=myFileSystem;AccessKey=myAccessKey;InitiateOAuth=GETANDREFRESH" conn = java.sql.DriverManager.getConnection(url) stmt = conn.createStatement rs = stmt.executeQuery("SELECT FullPath, Permission FROM Resources") while (rs.next) do puts rs.getString(1) + ' ' + rs.getString(2) end

ファイルが完成したら、コマンドラインからファイルを実行するだけでJRuby でAzure Data Lake Storage を表示できるようになります。

jruby -S ADLSSelect.rb

SQL-92 クエリをAzure Data Lake Storage に書き込むと、Azure Data Lake Storage を独自のJRuby アプリケーションに素早く簡単に組み込むことができます。今すぐ無料トライアルをダウンロードしましょう。