Ready to get started?

Download a free trial of the TaxJar Driver to get started:

 Download Now

Learn more:

TaxJar Icon TaxJar JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with TaxJar.

Create a Data Access Object for TaxJar Data using JDBI

A brief overview of creating a SQL Object API for TaxJar 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 TaxJar integrates connectivity to live TaxJar data in Java applications. By pairing these technologies, you gain simple, programmatic access to TaxJar data. This article walks through building a basic Data Access Object (DAO) and the accompanying code to read and write TaxJar data.

Create a DAO for the TaxJar Orders 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 MyOrdersDAO { //insert new data into TaxJar @SqlUpdate("INSERT INTO Orders (TransactionID, UserID) values (:transactionID, :userID)") void insert(@Bind("transactionID") String transactionID, @Bind("userID") String userID); //request specific data from TaxJar (String type is used for simplicity) @SqlQuery("SELECT UserID FROM Orders WHERE TransactionID = :transactionID") String findUserIDByTransactionID(@Bind("transactionID") String transactionID); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to TaxJar

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to TaxJar.

To authenticate to the TaxJar API, you will need to first obtain the API Key from the TaxJar UI.

NOTE: the API is available only for Professional and Premium TaxJar plans.

If you already have a Professional or Premium plan you can find the API Key by logging in the TaxJar UI and navigating to Account -> TaxJar API. After obtaining the API Key, you can set it in the APIKey connection property.

Additional Notes

  • By default, the CData connector will retrieve data of the last 3 months in cases where the entity support date range filtering. You can set StartDate to specify the minimum creation date of the data retrieved.
  • If the API Key has been created for a sandbox API account please set UseSandbox to true, but not all endpoints will work as expected. For more information, refer to the TaxJar developer documentation.

Built-in Connection String Designer

For assistance in constructing the JDBC URL, use the connection string designer built into the TaxJar JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

java -jar cdata.jdbc.taxjar.jar

Fill in the connection properties and copy the connection string to the clipboard.

A connection string for TaxJar will typically look like the following:


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:taxjar:APIKey=3bb04218ef8t80efdf1739abf7257144;"); MyOrdersDAO dao =; //do stuff with the DAO dao.close();

Read TaxJar Data

With the connection open to TaxJar, simply call the previously defined method to retrieve data from the Orders entity in TaxJar.

//disply the result of our 'find' method String userID = dao.findUserIDByTransactionID("123"); System.out.println(userID);

Write TaxJar Data

It is also simple to write data to TaxJar, using the previously defined method.

//add a new entry to the Orders entity dao.insert(newTransactionID, newUserID);

Since the JDBI library is able to work with JDBC connections, you can easily produce a SQL Object API for TaxJar by integrating with the CData JDBC Driver for TaxJar. Download a free trial and work with live TaxJar data in custom Java applications today.