Connect to Jira Assets Data in JRuby



Create a simple JRuby app with access to live Jira Assets data.

JRuby is a high-performance, stable, fully threaded Java implementation of the Ruby programming language. The CData JDBC Driver for Jira Assets makes it easy to integrate connectivity to live Jira Assets data in JRuby. This article shows how to create a simple JRuby app that connects to Jira Assets data, executes a query, and displays the results.

Configure a JDBC Connection to Jira Assets Data

Before creating the app, note the installation location for the JAR file for the JDBC Driver (typically C:\Program Files\CData\CData JDBC Driver for Jira Assets\lib).

JRuby natively supports JDBC, so you can easily connect to Jira Assets and execute SQL queries. Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.

Jira Assets supports connecting and authenticating via the APIToken.

To generate an API token:

  1. Log in to your Atlassian account.
  2. Navigate to Security < Create and manage API Token < Create API Token.

Atlassian generates and then displays the API token.

After you have generated the API token, set these parameters:

  • AuthScheme: APIToken.
  • User: The login of the authenticating user.
  • APIToken: The API token you just generated.

You are now ready to connect and authenticate to Jira Assets.

Built-in Connection String Designer

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

java -jar cdata.jdbc.jiraassets.jar

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

Below is a typical JDBC connection string for Jira Assets:

jdbc:jiraassets:User=MyUser;APIToken=myApiToken;Url=https://yoursitename.atlassian.net

Create a JRuby App with Connectivity to Jira Assets Data

Create a new Ruby file (for example: JiraAssetsSelect.rb) and open it in a text editor. Copy the following code into your file:

require 'java' require 'rubygems' require 'C:/Program Files/CData/CData JDBC Driver for Jira Assets 2018/lib/cdata.jdbc.jiraassets.jar' url = "jdbc:jiraassets:User=MyUser;APIToken=myApiToken;Url=https://yoursitename.atlassian.net" conn = java.sql.DriverManager.getConnection(url) stmt = conn.createStatement rs = stmt.executeQuery("SELECT ID, Name FROM Objects") while (rs.next) do puts rs.getString(1) + ' ' + rs.getString(2) end

With the file completed, you are ready to display your Jira Assets data with JRuby. To do so, simply run your file from the command line:

jruby -S JiraAssetsSelect.rb

Writing SQL-92 queries to Jira Assets allows you to quickly and easily incorporate Jira Assets data into your own JRuby applications. Download a free trial today!

Ready to get started?

Download a free trial of the Jira Assets Driver to get started:

 Download Now

Learn more:

Jira Assets Icon Jira Assets JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Jira Assets.