Ready to get started?

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

Download Now

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

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

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

Oracle Eloqua Campaign 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 MyCampaignDAO { //insert new data into Oracle Eloqua @SqlUpdate("INSERT INTO Campaign (ShipCity, ActualCost) values (:shipCity, :actualCost)") void insert(@Bind("shipCity") String shipCity, @Bind("actualCost") String actualCost); //request specific data from Oracle Eloqua (String type is used for simplicity) @SqlQuery("SELECT ActualCost FROM Campaign WHERE ShipCity = :shipCity") String findActualCostByShipCity(@Bind("shipCity") String shipCity); /* * close with no args is used to close the connection */ void close(); }

Oracle Eloqua への接続を開く

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Oracle Eloqua.

There are two authentication methods available for connecting to Oracle Eloqua: Login and OAuth. The Login method requires you to have the Company, User, and Password of the user.

If you do not have access to the username and password or do not wish to require them, you can use OAuth authentication. OAuth is better suited for allowing other users to access their own data. Using login credentials is better suited for accessing your own data.

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

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

java -jar cdata.jdbc.oracleeloqua.jar

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

A connection string for Oracle Eloqua will typically look like the following:

jdbc:oracleeloqua:User=user;Password=password;Company=CData;

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:oracleeloqua:User=user;Password=password;Company=CData;"); MyCampaignDAO dao = dbi.open(MyCampaignDAO.class); //do stuff with the DAO dao.close();

Oracle Eloqua Data について

With the connection open to Oracle Eloqua, simply call the previously defined method to retrieve data from the Campaign entity in Oracle Eloqua.

//disply the result of our 'find' method String actualCost = dao.findActualCostByShipCity("New York"); System.out.println(actualCost);

Oracle Eloqua Data の書き方

It is also simple to write data to Oracle Eloqua, using the previously defined method.

//add a new entry to the Campaign entity dao.insert(newShipCity, newActualCost);

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

 
 
ダウンロード