今すぐお試しください!

製品の詳細CData JDBC Driver for Exchange を確認して、無償評価版をダウンロード:

今すぐダウンロード

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

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

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

Microsoft Exchange Contacts 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 MyContactsDAO { //insert new data into Microsoft Exchange @SqlUpdate("INSERT INTO Contacts (BusinnessAddress_City, Size) values (:businnessAddress_City, :size)") void insert(@Bind("businnessAddress_City") String businnessAddress_City, @Bind("size") String size); //request specific data from Microsoft Exchange (String type is used for simplicity) @SqlQuery("SELECT Size FROM Contacts WHERE BusinnessAddress_City = :businnessAddress_City") String findSizeByBusinnessAddress_City(@Bind("businnessAddress_City") String businnessAddress_City); /* * close with no args is used to close the connection */ void close(); }

Microsoft Exchange への接続を開く

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Microsoft Exchange.

Specify the User and Password to connect to Exchange. Additionally, specify the address of the Exchange server you are connecting to and the Platform associated with the server.

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

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

java -jar cdata.jdbc.exchange.jar

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

A connection string for Microsoft Exchange will typically look like the following:

jdbc:exchange:User='myUser@mydomain.onmicrosoft.com';Password='myPassword';Server='https://outlook.office365.com/EWS/Exchange.asmx';Platform='Exchange_Online';

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:exchange:User='myUser@mydomain.onmicrosoft.com';Password='myPassword';Server='https://outlook.office365.com/EWS/Exchange.asmx';Platform='Exchange_Online';"); MyContactsDAO dao = dbi.open(MyContactsDAO.class); //do stuff with the DAO dao.close();

Microsoft Exchange Data について

With the connection open to Microsoft Exchange, simply call the previously defined method to retrieve data from the Contacts entity in Microsoft Exchange.

//disply the result of our 'find' method String size = dao.findSizeByBusinnessAddress_City("Raleigh"); System.out.println(size);

Microsoft Exchange Data の書き方

It is also simple to write data to Microsoft Exchange, using the previously defined method.

//add a new entry to the Contacts entity dao.insert(newBusinnessAddress_City, newSize);

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

 
 
ダウンロード