Ready to get started?

Download a free trial of the Reckon Accounts Hosted Driver to get started:

 Download Now

Learn more:

Reckon Accounts Hosted Icon Reckon Accounts Hosted JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Reckon Accounts Hosted.

Create a Data Access Object for Reckon Accounts Hosted Data using JDBI



A brief overview of creating a SQL Object API for Reckon Accounts Hosted data in JDBI.

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 walks through building a basic Data Access Object (DAO) and the accompanying code to read and write Reckon Accounts Hosted data.

Create a DAO for the Reckon Accounts Hosted Accounts Entity

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(); }

Open a Connection to Reckon Accounts Hosted

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:

  • SubscriptionKey: Required. You get this value when you created your developer account.
  • CountryVersion: Defaults to 2021.R2.AU.
  • CompanyFile: Required. The path to the company file.
  • User: Required. The username of the company file.
  • Password: Required. The password of the company file.
  • InitiateOAuth: Set this to GETANDREFRESH to let the driver handle access tokens.
  • CallbackURL: The redirectURI of your Custom OAuth App.
  • OAuthClientId: The client id of your Custom OAuth App.
  • OAuthClientSecret: The client secret of your Custom OAuth App.

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.

Built-in Connection String Designer

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.

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();

Read Reckon Accounts Hosted Data

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);

Write Reckon Accounts Hosted Data

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.