Ready to get started?

Learn more about the CData JDBC Driver for Adobe Analytics or download a free trial:

Download Now

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

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

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

Adobe Analytics AdsReport Entity のDAO を作成

The interface below declares the desired behavior for the SQL object to create a single method for each SQL statement to be implemented.

public interface MyAdsReportDAO { //request specific data from Adobe Analytics (String type is used for simplicity) @SqlQuery("SELECT PageViews FROM AdsReport WHERE City = :city") String findPageViewsByCity(@Bind("city") String city); /* * close with no args is used to close the connection */ void close(); }

Adobe Analytics への接続を開く

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Adobe Analytics.

Adobe Analytics uses the OAuth authentication standard. To authenticate using OAuth, you will need to create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the "Getting Started" section of the help documentation for a guide.

Retrieving GlobalCompanyId

GlobalCompanyId is a required connection property. If you do not know your Global Company ID, you can find it in the request URL for the users/me endpoint on the Swagger UI. After logging into the Swagger UI Url, expand the users endpoint and then click the GET users/me button. Click the Try it out and Execute buttons. Note your Global Company ID shown in the Request URL immediately preceding the users/me endpoint.

Retrieving Report Suite Id

Report Suite ID (RSID) is also a required connection property. In the Adobe Analytics UI, navigate to Admin -> Report Suites and you will get a list of your report suites along with their identifiers next to the name.

After setting the GlobalCompanyId, RSID and OAuth connection properties, you are ready to connect to Adobe Analytics.

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

For assistance in constructing the JDBC URL, use the connection string designer built into the Adobe Analytics JDBC Driver.Either double-click the JAR file or execute the jar file from the command-line.

java -jar cdata.jdbc.adobeanalytics.jar

Fill in the connection properties and copy the connection string to the clipboard.

A connection string for Adobe Analytics will typically look like the following:

jdbc:adobeanalytics:GlobalCompanyId=myGlobalCompanyId; RSID=myRSID; OAuthClientId=myOauthClientId; OauthClientSecret=myOAuthClientSecret; CallbackURL=myCallbackURL;

Use the configured JDBC URL to obtain an instance of the DAO interface.The particular method shown below will open a handle bound to the instance, so the instance needs to be closed explicitly to release the handle and the bound JDBC connection.

DBI dbi = new DBI("jdbc:adobeanalytics:GlobalCompanyId=myGlobalCompanyId; RSID=myRSID; OAuthClientId=myOauthClientId; OauthClientSecret=myOAuthClientSecret; CallbackURL=myCallbackURL;"); MyAdsReportDAO dao = dbi.open(MyAdsReportDAO.class); //do stuff with the DAO dao.close();

Adobe Analytics Data について

With the connection open to Adobe Analytics, simply call the previously defined method to retrieve data from the AdsReport entity in Adobe Analytics.

//disply the result of our 'find' method String pageViews = dao.findPageViewsByCity("Chapel Hill"); System.out.println(pageViews);

Since the JDBI library is able to work with JDBC connections, you can easily produce a SQL Object API for Adobe Analytics by integrating with the CData JDBC Driver for Adobe Analytics.Download a free trial and work with live Adobe Analytics data in custom Java applications today.

 
 
ダウンロード