Ready to get started?

Download a free trial of the Tableau CRM Analytics Driver to get started:

 Download Now

Learn more:

Tableau CRM Analytics Icon Tableau CRM Analytics JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Tableau CRM Analytics.

Create a Data Access Object for Tableau CRM Analytics Data using JDBI

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

Create a DAO for the Tableau CRM Analytics Dataset_Opportunity 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 MyDataset_OpportunityDAO { //insert new data into Tableau CRM Analytics @SqlUpdate("INSERT INTO Dataset_Opportunity (StageName, CloseDate) values (:stageName, :closeDate)") void insert(@Bind("stageName") String stageName, @Bind("closeDate") String closeDate); //request specific data from Tableau CRM Analytics (String type is used for simplicity) @SqlQuery("SELECT CloseDate FROM Dataset_Opportunity WHERE StageName = :stageName") String findCloseDateByStageName(@Bind("stageName") String stageName); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Tableau CRM Analytics

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Tableau CRM Analytics.

Tableau CRM Analytics uses the OAuth 2 authentication standard. You will need to obtain the OAuthClientId and OAuthClientSecret by registering an app with Tableau CRM Analytics.

See the Getting Started section of the Help documentation for an authentication guide.

Built-in Connection String Designer

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

java -jar cdata.jdbc.tableaucrm.jar

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

A connection string for Tableau CRM Analytics 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:tableaucrm:OAuthClientId=MyConsumerKey;OAuthClientSecret=MyConsumerSecret;CallbackURL=http://localhost:portNumber;InitiateOAuth=GETANDREFRESH"); MyDataset_OpportunityDAO dao =; //do stuff with the DAO dao.close();

Read Tableau CRM Analytics Data

With the connection open to Tableau CRM Analytics, simply call the previously defined method to retrieve data from the Dataset_Opportunity entity in Tableau CRM Analytics.

//disply the result of our 'find' method String closeDate = dao.findCloseDateByStageName("Closed Won"); System.out.println(closeDate);

Write Tableau CRM Analytics Data

It is also simple to write data to Tableau CRM Analytics, using the previously defined method.

//add a new entry to the Dataset_Opportunity entity dao.insert(newStageName, newCloseDate);

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