![]() |
VOOZH | about |
JRuby is a high-performance, stable, fully threaded Java implementation of the Ruby programming language. The CData JDBC Driver for Certinia makes it easy to integrate connectivity to live Certinia data in JRuby. This article shows how to create a simple JRuby app that connects to Certinia 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 Certinia\lib).
JRuby natively supports JDBC, so you can easily connect to Certinia and execute SQL queries. Initialize the JDBC connection with the getConnection function of the java.sql.DriverManager class.
There are several authentication methods available for connecting to Certinia: login credentials, SSO, and OAuth.
Set the User and Password to your login credentials. Additionally, set the SecurityToken. By default, the SecurityToken is required, but you can make it optional by allowing a range of trusted IP addresses.
To disable the security token:
To obtain the security token:
If you do not have access to the user name and password or do not want to require them, use the OAuth user consent flow. See the OAuth section in the Help for an authentication guide.
Set UseSandbox to true (false by default) to use a Certinia sandbox account. Ensure that you specify a sandbox user name in User.
For assistance in constructing the JDBC URL, use the connection string designer built into the Certinia JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.certinia.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 Certinia:
jdbc:certinia:User=myUser;Password=myPassword;Security Token=myToken;InitiateOAuth=GETANDREFRESH;
Create a new Ruby file (for example: CertiniaSelect.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 Certinia 2018/lib/cdata.jdbc.certinia.jar'
url = "jdbc:certinia:User=myUser;Password=myPassword;Security Token=myToken;InitiateOAuth=GETANDREFRESH;"
conn = java.sql.DriverManager.getConnection(url)
stmt = conn.createStatement
rs = stmt.executeQuery("SELECT BillingState, Name FROM Account")
while (rs.next) do
puts rs.getString(1) + ' ' + rs.getString(2)
end
With the file completed, you are ready to display your Certinia data with JRuby. To do so, simply run your file from the command line:
jruby -S CertiniaSelect.rb
Writing SQL-92 queries to Certinia allows you to quickly and easily incorporate Certinia data into your own JRuby applications. Download a free trial today!
Download a free trial of the Certinia Driver to get started:
Download NowLearn more:
👁 Certinia IconRapidly create and deploy powerful Java applications that integrate with Certinia.