Ready to get started?

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

 Download Now

Learn more:

QuickBooks Icon QuickBooks JDBC Driver

Complete read-write access to QuickBooks enables developers to search (Customers, Transactions, Invoices, Sales Receipts, etc.), update items, edit customers, and more, from any Java/J2EE application.

Create a Data Access Object for QuickBooks Data using JDBI

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

Create a DAO for the QuickBooks Customers 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 MyCustomersDAO { //insert new data into QuickBooks @SqlUpdate("INSERT INTO Customers (Type, CustomerBalance) values (:type, :customerBalance)") void insert(@Bind("type") String type, @Bind("customerBalance") String customerBalance); //request specific data from QuickBooks (String type is used for simplicity) @SqlQuery("SELECT CustomerBalance FROM Customers WHERE Type = :type") String findCustomerBalanceByType(@Bind("type") String type); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to QuickBooks

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

When you are connecting to a local QuickBooks instance, you do not need to set any connection properties.

Requests are made to QuickBooks through the Remote Connector. The Remote Connector runs on the same machine as QuickBooks and accepts connections through a lightweight, embedded Web server. The server supports SSL/TLS, enabling users to connect securely from remote machines.

The first time you connect, you will need to authorize the Remote Connector with QuickBooks. See the "Getting Started" chapter of the help documentation for a guide.

Built-in Connection String Designer

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

java -jar cdata.jdbc.quickbooks.jar

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

A connection string for QuickBooks 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:quickbooks:URL=http://remotehost:8166;User=admin;Password=admin123;"); MyCustomersDAO dao =; //do stuff with the DAO dao.close();

Read QuickBooks Data

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

//disply the result of our 'find' method String customerBalance = dao.findCustomerBalanceByType("Commercial"); System.out.println(customerBalance);

Write QuickBooks Data

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

//add a new entry to the Customers entity dao.insert(newType, newCustomerBalance);

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