![]() |
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 QuickBooks integrates connectivity to live QuickBooks data in Java applications. By pairing these technologies, you gain simple, programmatic access to QuickBooks data. This article explains how to build a basic Data Access Object (DAO) and the accompanying code to read and write QuickBooks data.
CData simplifies access and integration of live QuickBooks data. Our customers leverage CData connectivity to:
Customers regularly integrate their QuickBooks data with preferred tools, like Power BI, Tableau, or Excel, and integrate QuickBooks data into their database or data warehouse.
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();
}
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, authorize the Remote Connector with QuickBooks. See the "Getting Started" chapter of the help documentation for a guide.
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.
👁 Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)A connection string for QuickBooks will typically look like the following:
jdbc:quickbooks:URL=http://remotehost:8166;User=admin;Password=admin123;
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 = dbi.open(MyCustomersDAO.class);
//do stuff with the DAO
dao.close();
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);
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.
Download a free trial of the QuickBooks Driver to get started:
Download NowLearn more:
👁 QuickBooks IconComplete 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.