Ready to get started?

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

 Download Now

Learn more:

Intacct Icon Intacct JDBC Driver

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

Create a Data Access Object for Sage Intacct Data using JDBI



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

Create a DAO for the Sage Intacct Customer 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 MyCustomerDAO { //insert new data into Sage Intacct @SqlUpdate("INSERT INTO Customer (CustomerId, TotalDue) values (:customerId, :totalDue)") void insert(@Bind("customerId") String customerId, @Bind("totalDue") String totalDue); //request specific data from Sage Intacct (String type is used for simplicity) @SqlQuery("SELECT TotalDue FROM Customer WHERE CustomerId = :customerId") String findTotalDueByCustomerId(@Bind("customerId") String customerId); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Sage Intacct

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

To connect using the Login method, the following connection properties are required: User, Password, CompanyId, SenderId and SenderPassword.

User, Password, and CompanyId are the credentials for the account you wish to connect to.

SenderId and SenderPassword are the Web Services credentials assigned to you by Sage Intacct.

Built-in Connection String Designer

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

java -jar cdata.jdbc.sageintacct.jar

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

A connection string for Sage Intacct will typically look like the following:

jdbc:sageintacct:User=myusername;CompanyId=TestCompany;Password=mypassword;SenderId=Test;SenderPassword=abcde123;

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:sageintacct:User=myusername;CompanyId=TestCompany;Password=mypassword;SenderId=Test;SenderPassword=abcde123;"); MyCustomerDAO dao = dbi.open(MyCustomerDAO.class); //do stuff with the DAO dao.close();

Read Sage Intacct Data

With the connection open to Sage Intacct, simply call the previously defined method to retrieve data from the Customer entity in Sage Intacct.

//disply the result of our 'find' method String totalDue = dao.findTotalDueByCustomerId("12345"); System.out.println(totalDue);

Write Sage Intacct Data

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

//add a new entry to the Customer entity dao.insert(newCustomerId, newTotalDue);

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