Ready to get started?

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

 Download Now

Learn more:

QuickBooks POS Icon QuickBooks POS JDBC Driver

Complete read-write access to QuickBooks Point of Sale 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 POS Data using JDBI



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

Create a DAO for the QuickBooks POS 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 POS @SqlUpdate("INSERT INTO Customers (LastName, AccountLimit) values (:lastName, :accountLimit)") void insert(@Bind("lastName") String lastName, @Bind("accountLimit") String accountLimit); //request specific data from QuickBooks POS (String type is used for simplicity) @SqlQuery("SELECT AccountLimit FROM Customers WHERE LastName = :lastName") String findAccountLimitByLastName(@Bind("lastName") String lastName); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to QuickBooks POS

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

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

Requests are made to QuickBooks POS through the Remote Connector. The Remote Connector runs on the same machine as QuickBooks POS 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 POS. 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 POS JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

java -jar cdata.jdbc.quickbookspos.jar

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

A connection string for QuickBooks POS will typically look like the following:

jdbc:quickbookspos:

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:quickbookspos:"); MyCustomersDAO dao = dbi.open(MyCustomersDAO.class); //do stuff with the DAO dao.close();

Read QuickBooks POS Data

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

//disply the result of our 'find' method String accountLimit = dao.findAccountLimitByLastName("Cook"); System.out.println(accountLimit);

Write QuickBooks POS Data

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

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

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