![]() |
VOOZH | about |
JRuby is a high-performance, stable, fully threaded Java implementation of the Ruby programming language. The CData JDBC Driver for Zuora makes it easy to integrate connectivity to live Zuora data in JRuby. This article shows how to create a simple JRuby app that connects to Zuora 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 Zuora\lib).
JRuby natively supports JDBC, so you can easily connect to Zuora and execute SQL queries. Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.
Zuora uses the OAuth standard to authenticate users. See the online Help documentation for a full OAuth authentication guide.
In order to create a valid connection with the provider you need to choose one of the Tenant values (USProduction by default) which matches your account configuration. The following is a list with the available options:
Two Zuora services are available: Data Query and AQuA API. By default ZuoraService is set to AQuADataExport.
The Data Query feature enables you to export data from your Zuora tenant by performing asynchronous, read-only SQL queries. We recommend to use this service for quick lightweight SQL queries.
LimitationsAQuA API export is designed to export all the records for all the objects ( tables ). AQuA query jobs have the following limitations:
LimitationsFor assistance in constructing the JDBC URL, use the connection string designer built into the Zuora JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.zuora.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 Zuora:
jdbc:zuora:OAuthClientID=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;Tenant=USProduction;ZuoraService=DataQuery;InitiateOAuth=GETANDREFRESH;
Create a new Ruby file (for example: ZuoraSelect.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 Zuora 2018/lib/cdata.jdbc.zuora.jar'
url = "jdbc:zuora:OAuthClientID=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;Tenant=USProduction;ZuoraService=DataQuery;InitiateOAuth=GETANDREFRESH;"
conn = java.sql.DriverManager.getConnection(url)
stmt = conn.createStatement
rs = stmt.executeQuery("SELECT Id, BillingCity FROM Invoices")
while (rs.next) do
puts rs.getString(1) + ' ' + rs.getString(2)
end
With the file completed, you are ready to display your Zuora data with JRuby. To do so, simply run your file from the command line:
jruby -S ZuoraSelect.rb
Writing SQL-92 queries to Zuora allows you to quickly and easily incorporate Zuora data into your own JRuby applications. Download a free trial today!
Download a free trial of the Zuora Driver to get started:
Download NowLearn more:
👁 Zuora IconRapidly create and deploy powerful Java applications that integrate with Zuora.