製品をチェック

無償トライアル:

無償トライアルへ

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

Azure Data Lake Storage JDBC Driver

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

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

お問い合わせ

ColdFusion でAzure Data Lake Storage データに連携する方法


ColdFusion の標準的なデータアクセスコードでAzure Data Lake Storage にデータ連携。


加藤龍彦
ウェブデベロッパー



CData JDBC Driver for ADLS は、ColdFusion のrapid development tools を使ってAzure Data Lake Storage への接続をシームレスに統合します。この記事では、ColdFusion でAzure Data Lake Storage に連携しAzure Data Lake Storage テーブルをクエリする方法を説明します。

ColdFusion にAzure Data Lake Storage のJDBC データソースを作成

下記の手順に従ってAzure Data Lake Storage データソースを作成し、ColdFusion アプリケーションへの連携を可能にします。

  1. ドライバーのJAR および.lic ファイルを、インストールディレクトリから C:\ColdFusion10\cfusion\wwwroot\WEB-INF\lib にコピーします。

    ドライバーのJAR およびlicense はインストールディレクトリの[lib]サブフォルダに配置されています。

  2. ドライバーをデータソースとして追加:

    ColdFusion Administrator インターフェースで[Data & Services]ノードを展開し、[Data Sources]>[Add New Data Source]をクリックします。ダイアログが表示されたら、以下のプロパティを入力します。

    • Data Source Name:データソースの名前を入力。名前はColdFusion 変数命名規則に一致する必要があります。
    • Driver:[Other]を選択。
    Adding a JDBC data source to ColdFusion. (Salesforce is shown.)
  3. JDBC Driver のプロパティ設定:

    • JDBC URL:JDBC URL に接続プロパティを入力。JDBC のURL は以下で始まり jdbc:adls: 次に、セミコロン区切りでname=value ペアの接続プロパティを入力します。以下は一般的なJDBC URL です:

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

      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.
    • Driver Class:ドライバーのクラスを入力。ドライバークラスは、以下のとおりです。cdata.jdbc.adls.ADLSDriver
    • Driver Name:ユーザー定義のドライバー名を入力。ドライバー名はColdFusion Administrator コンソールでデータソースを認識するために使われます。
    • Username:認証するユーザーネームを入力。
    • Password:認証するパスワードを入力。
Required connection properties specified in the JDBC URL. (Salesforce is shown.)

[Actions] カラムのCData Azure Data Lake Storage データソースを有効にして、接続をテストできます。ステータスがOK になったら、Azure Data Lake Storage データソースを使うことができます。

Test the connection in the Actions column. (Salesforce is shown.)

クエリを実行

下記の手順に従って、Azure Data Lake Storage の基準に合ったレコードをクエリし、結果をHTML テーブルに出力する簡単なアプリケーションを作成します。

  1. 新規ColdFusion markup ファイルでクエリを定義:C:\ColdFusion10\cfusion\wwwroot directory for ColdFusion の.cfm ファイルに次のコードを入力:

    <cfquery name="ADLSQuery" dataSource="CDataADLS"> SELECT * FROM Resources </cfquery>

    Note:CData JDBC Drivers は、cfqueryparam エレメントを使ってパラメータ化されたクエリもサポートします。例:

    <cfquery name="ADLSQuery" dataSource="CDataADLS"> SELECT * FROM Resources WHERE Type = <cfqueryparam>FILE</cfqueryparam> </cfquery>
  2. CFTable を使ってHTML にテーブルを出力:

    <cftable query = "ADLSQuery" border = "1" colHeaders colSpacing = "2" headerLines = "2" HTMLTable maxRows = "500" startRow = "1"/> <cfcol header="<b>FullPath</b>" align="Left" width=8 text="#FullPath#"></cfcol> <cfcol header="<b>Permission</b>" align="Left" width=10 text="#Permission#"></cfcol> </cftable>
  3. コードを実行してグリッドを表示します。

    Query results in an HTML table. (Salesforce is shown.)

HTML 部分を含む以下のフルコードが利用できます。

<html> <head><title>Hello World</title></head> <body> <cfoutput>#ucase("hello world")#</cfoutput> <cfquery name="ADLSQuery" dataSource="CDataADLS"> SELECT * FROM Resources </cfquery> <cftable query = "ADLSQuery" border = "1" colHeaders colSpacing = "2" headerLines = "2" HTMLTable maxRows = "500" startRow = "1"> <cfcol header="<b>FullPath</b>" align="Left" width=8 text="#FullPath#"></cfcol> <cfcol header="<b>Permission</b>" align="Left" width=10 text="#Permission#"></cfcol> </cftable> </body> </html>