Ready to get started?

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

Download Now

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

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

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

Btrieve Billing 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 MyBillingDAO { //insert new data into Btrieve @SqlUpdate("INSERT INTO Billing (Student_ID, Transaction_Number) values (:student_ID, :transaction_Number)") void insert(@Bind("student_ID") String student_ID, @Bind("transaction_Number") String transaction_Number); //request specific data from Btrieve (String type is used for simplicity) @SqlQuery("SELECT Transaction_Number FROM Billing WHERE Student_ID = :student_ID") String findTransaction_NumberByStudent_ID(@Bind("student_ID") String student_ID); /* * close with no args is used to close the connection */ void close(); }

Btrieve への接続を開く

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

The PSQL v13 client will need to be installed on the same machine as the driver. To connect, set the User, Password, Server, and Database properties.


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

java -jar cdata.jdbc.btrieve.jar

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

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


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:btrieve:User=myuser;Password=mypassword;Server=myserver;Database=mydatabase;"); MyBillingDAO dao =; //do stuff with the DAO dao.close();

Btrieve Data について

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

//disply the result of our 'find' method String transaction_Number = dao.findTransaction_NumberByStudent_ID("22"); System.out.println(transaction_Number);

Btrieve Data の書き方

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

//add a new entry to the Billing entity dao.insert(newStudent_ID, newTransaction_Number);

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