Ready to get started?

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

Download Now

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

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

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

Zendesk Tickets 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 MyTicketsDAO { //insert new data into Zendesk @SqlUpdate("INSERT INTO Tickets (Industry, Subject) values (:industry, :subject)") void insert(@Bind("industry") String industry, @Bind("subject") String subject); //request specific data from Zendesk (String type is used for simplicity) @SqlQuery("SELECT Subject FROM Tickets WHERE Industry = :industry") String findSubjectByIndustry(@Bind("industry") String industry); /* * close with no args is used to close the connection */ void close(); }

Zendesk への接続を開く

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

Connecting to Zendesk

To connect, set the URL and provide authentication. The URL is your Zendesk Support URL: https://{subdomain}

Authenticating to Zendesk

You can authenticate using the Basic or OAuth methods.

Using Basic Authentication

To use Basic authentication, specify your email address and password or your email address and an API token. Set User to your email address and follow the steps below to provide the Password or ApiToken.

  • Enable password access in the Zendesk Support admin interface at Admin > Channels > API.
  • Manage API tokens in the Zendesk Support Admin interface at Admin > Channels > API. More than one token can be active at the same time. Deleting a token deactivates it permanently.

Using OAuth Authentication

See the Getting Started guide in the CData driver documentation for an authentication guide.


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

java -jar cdata.jdbc.zendesk.jar

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

A connection string for Zendesk 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:zendesk:URL=;;Password=test123;InitiateOAuth=GETANDREFRESH"); MyTicketsDAO dao =; //do stuff with the DAO dao.close();

Zendesk Data について

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

//disply the result of our 'find' method String subject = dao.findSubjectByIndustry("Floppy Disks"); System.out.println(subject);

Zendesk Data の書き方

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

//add a new entry to the Tickets entity dao.insert(newIndustry, newSubject);

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