Ready to get started?

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

Download Now

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

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

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

Reckon Customers 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 MyCustomersDAO { //insert new data into Reckon @SqlUpdate("INSERT INTO Customers (Type, CustomerBalance) values (:type, :customerBalance)") void insert(@Bind("type") String type, @Bind("customerBalance") String customerBalance); //request specific data from Reckon (String type is used for simplicity) @SqlQuery("SELECT CustomerBalance FROM Customers WHERE Type = :type") String findCustomerBalanceByType(@Bind("type") String type); /* * close with no args is used to close the connection */ void close(); }

Reckon への接続を開く

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

When you are connecting to a local Reckon instance, you do not need to set any connection properties.

Requests to Reckon are made through the Remote Connector. The Remote Connector runs on the same machine as Reckon and accepts connections through a lightweight, embedded Web server. The server supports SSL/TLS, enabling users to connect securely from remote machines.

The first time you connect to your company file, you will need to authorize the Remote Connector with Reckon. See the "Getting Started" chapter of the help documentation for a guide.

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

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

java -jar cdata.jdbc.reckon.jar

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

A connection string for Reckon will typically look like the following:

jdbc:reckon:User=RCUser;Password=RCUserPassword;URL=http://remotehost:8166;

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:reckon:User=RCUser;Password=RCUserPassword;URL=http://remotehost:8166;"); MyCustomersDAO dao = dbi.open(MyCustomersDAO.class); //do stuff with the DAO dao.close();

Reckon Data について

With the connection open to Reckon, simply call the previously defined method to retrieve data from the Customers entity in Reckon.

//disply the result of our 'find' method String customerBalance = dao.findCustomerBalanceByType("Commercial"); System.out.println(customerBalance);

Reckon Data の書き方

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

//add a new entry to the Customers entity dao.insert(newType, newCustomerBalance);

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

 
 
ダウンロード