![]() |
VOOZH | about |
JDBI is a SQL convenience library for Java that exposes two different style APIs, a fluent style and a SQL object style. The CData JDBC Driver for Reckon Accounts Hosted integrates connectivity to live Reckon Accounts Hosted data in Java applications. By pairing these technologies, you gain simple, programmatic access to Reckon Accounts Hosted data. This article explains how to build a basic Data Access Object (DAO) and the accompanying code to read and write Reckon Accounts Hosted data.
The interface below declares the desired behavior for the SQL object to create a single method for each SQL statement to be implemented.
public interface MyAccountsDAO {
//insert new data into Reckon Accounts Hosted
@SqlUpdate("INSERT INTO Accounts (IsActive, Balance) values (:isActive, :balance)")
void insert(@Bind("isActive") String isActive, @Bind("balance") String balance);
//request specific data from Reckon Accounts Hosted (String type is used for simplicity)
@SqlQuery("SELECT Balance FROM Accounts WHERE IsActive = :isActive")
String findBalanceByIsActive(@Bind("isActive") String isActive);
/*
* close with no args is used to close the connection
*/
void close();
}
Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Reckon Accounts Hosted.
The connector makes requests to Reckon Accounts Hosted through OAuth. Specify the following connection properties:
CData provides an embedded OAuth application that simplifies OAuth desktop authentication. See the Help documentation for information on other OAuth authentication methods (web, headless, etc.), creating custom OAuth applications, and reasons for doing so.
For assistance in constructing the JDBC URL, use the connection string designer built into the Reckon Accounts Hosted JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.reckonaccountshosted.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.)A connection string for Reckon Accounts Hosted will typically look like the following:
jdbc:reckonaccountshosted:SubscriptionKey=my_subscription_key;CountryVersion=2021.R2.AU;CompanyFile=Q:/CompanyName.QBW;User=my_user;Password=my_password;CallbackURL=http://localhost:33333;OAuthClientId=my_oauth_client_id;OAuthClientSecret=my_oauth_client_secret;InitiateOAuth=GETANDREFRESH;
Use the configured JDBC URL to obtain an instance of the DAO interface. The particular method shown below will open a handle bound to the instance, so the instance needs to be closed explicitly to release the handle and the bound JDBC connection.
DBI dbi = new DBI("jdbc:reckonaccountshosted:SubscriptionKey=my_subscription_key;CountryVersion=2021.R2.AU;CompanyFile=Q:/CompanyName.QBW;User=my_user;Password=my_password;CallbackURL=http://localhost:33333;OAuthClientId=my_oauth_client_id;OAuthClientSecret=my_oauth_client_secret;InitiateOAuth=GETANDREFRESH;");
MyAccountsDAO dao = dbi.open(MyAccountsDAO.class);
//do stuff with the DAO
dao.close();
With the connection open to Reckon Accounts Hosted, simply call the previously defined method to retrieve data from the Accounts entity in Reckon Accounts Hosted.
//disply the result of our 'find' method
String balance = dao.findBalanceByIsActive("true");
System.out.println(balance);
It is also simple to write data to Reckon Accounts Hosted, using the previously defined method.
//add a new entry to the Accounts entity dao.insert(newIsActive, newBalance);
Since the JDBI library is able to work with JDBC connections, you can easily produce a SQL Object API for Reckon Accounts Hosted by integrating with the CData JDBC Driver for Reckon Accounts Hosted. Download a free trial and work with live Reckon Accounts Hosted data in custom Java applications today.
Download a free trial of the Reckon Accounts Hosted Driver to get started:
Download NowLearn more:
👁 Reckon Accounts Hosted IconRapidly create and deploy powerful Java applications that integrate with Reckon Accounts Hosted.