![]() |
VOOZH | about |
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.
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:
Atlassian generates and then displays the API token.
After you have generated the API token, set these parameters:
You are now ready to connect and authenticate to Jira Assets.
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.
👁 Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)Below is a typical JDBC connection string for Jira Assets:
jdbc:jiraassets:User=MyUser;APIToken=myApiToken;Url=https://yoursitename.atlassian.net
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!
Download a free trial of the Jira Assets Driver to get started:
Download NowLearn more:
👁 Jira Assets IconRapidly create and deploy powerful Java applications that integrate with Jira Assets.