製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

Jira Service Desk JDBC Driver

Jira Service Desk データに連携するJava アプリケーションを素早く、簡単に開発できる便利なドライバー。

データ連携でお困りですか?

お問い合わせ

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


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


jiraservicedesk ロゴ画像
jdbc ロゴ画像

JDBC

JDBI ロゴ画像

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

Jira Service Desk Requests Entity のDAO を作成

以下のインターフェースは、実装されるSQL ステートメントごとに単一のメソッドを作成するためのSQL オブジェクトの正しい動作を宣言します。

public interface MyRequestsDAO { //insert new data into Jira Service Desk @SqlUpdate("INSERT INTO Requests (CurrentStatus, ReporterName) values (:currentStatus, :reporterName)") void insert(@Bind("currentStatus") String currentStatus, @Bind("reporterName") String reporterName); //request specific data from Jira Service Desk (String type is used for simplicity) @SqlQuery("SELECT ReporterName FROM Requests WHERE CurrentStatus = :currentStatus") String findReporterNameByCurrentStatus(@Bind("currentStatus") String currentStatus); /* * close with no args is used to close the connection */ void close(); }

Jira Service Desk への接続を開く

必要な接続プロパティを収集し、Jira Service Desk に接続するための適切なJDBC URL を作成します。

You can establish a connection to any Jira Service Desk Cloud account or Server instance.

Connecting with a Cloud Account

To connect to a Cloud account, you'll first need to retrieve an APIToken. To generate one, log in to your Atlassian account and navigate to API tokens > Create API token. The generated token will be displayed.

Supply the following to connect to data:

  • User: Set this to the username of the authenticating user.
  • APIToken: Set this to the API token found previously.

Connecting with a Service Account

To authenticate with a service account, you will need to supply the following connection properties:

  • User: Set this to the username of the authenticating user.
  • Password: Set this to the password of the authenticating user.
  • URL: Set this to the URL associated with your JIRA Service Desk endpoint. For example, https://yoursitename.atlassian.net.

Note: Password has been deprecated for connecting to a Cloud Account and is now used only to connect to a Server Instance.

Accessing Custom Fields

By default, the connector only surfaces system fields. To access the custom fields for Issues, set IncludeCustomFields.

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

JDBC URL の構成については、Jira Service Desk JDBC Driver に組み込まれている接続文字列デザイナーを使用してください。JAR ファイルのダブルクリック、またはコマンドラインからJAR ファイルを実行します。

java -jar cdata.jdbc.jiraservicedesk.jar

接続プロパティを入力し、接続文字列をクリップボードにコピーします。

Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)

Jira Service Desk の接続文字列は、通常次のようになります。

jdbc:jiraservicedesk:ApiKey=myApiKey;User=MyUser;InitiateOAuth=GETANDREFRESH

構成済みのJDBC URL を使用して、DAO インターフェースのインスタンスを取得します。以下に示す特定のメソッドはインスタンスにバインドされたハンドルを開くため、ハンドルとバインドされたJDBC 接続を開放するには、インスタンスを明示的に閉じる必要があります。

DBI dbi = new DBI("jdbc:jiraservicedesk:ApiKey=myApiKey;User=MyUser;InitiateOAuth=GETANDREFRESH"); MyRequestsDAO dao = dbi.open(MyRequestsDAO.class); //do stuff with the DAO dao.close();

Jira Service Desk Data について

Jira Service Desk への接続を開いた状態で以前定義したメソッドを呼び出すだけで、Jira Service Desk のRequests エンティティからデータを取得できます。

//disply the result of our 'find' method String reporterName = dao.findReporterNameByCurrentStatus("Open"); System.out.println(reporterName);

Jira Service Desk Data の書き方

以前定義した方法を使用すれば、Jira Service Desk にデータを書き込むことも簡単になります。

//add a new entry to the Requests entity dao.insert(newCurrentStatus, newReporterName);

JDBI ライブラリはJDBC 接続を処理できるため、CData JDBC Driver for JiraServiceDesk と統合することで、SQL Object API for JiraServiceDesk を簡単に作成できます。今すぐ無料トライアルをダウンロードし、Java アプリケーションでライブJira Service Desk を操作しましょう。