Ready to get started?

Download a free trial of the Salesforce Pardot Driver to get started:

 Download Now

Learn more:

Salesforce Pardot Icon Salesforce Pardot JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Salesforce Pardot.

Create a Data Access Object for Salesforce Pardot Data using JDBI



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

Create a DAO for the Salesforce Pardot Prospects 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 MyProspectsDAO { //insert new data into Salesforce Pardot @SqlUpdate("INSERT INTO Prospects (ProspectAccountId, Email) values (:prospectAccountId, :email)") void insert(@Bind("prospectAccountId") String prospectAccountId, @Bind("email") String email); //request specific data from Salesforce Pardot (String type is used for simplicity) @SqlQuery("SELECT Email FROM Prospects WHERE ProspectAccountId = :prospectAccountId") String findEmailByProspectAccountId(@Bind("prospectAccountId") String prospectAccountId); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Salesforce Pardot

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

Salesforce Pardot supports connecting through API Version, Username, Password and User Key.

  • ApiVersion: The Salesforce Pardot API version which the provided account can access. Defaults to 4.
  • User: The Username of the Salesforce Pardot account.
  • Password: The Password of the Salesforce Pardot account.
  • UserKey: The unique User Key for the Salesforce Pardot account. This key does not expire.
  • IsDemoAccount (optional): Set to TRUE to connect to a demo account.

Accessing the Pardot User Key

The User Key of the current account may be accessed by going to Settings -> My Profile, under the API User Key row.

Built-in Connection String Designer

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

java -jar cdata.jdbc.salesforcepardot.jar

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

A connection string for Salesforce Pardot will typically look like the following:

jdbc:salesforcepardot:ApiVersion=4;User=YourUsername;Password=YourPassword;UserKey=YourUserKey;

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:salesforcepardot:ApiVersion=4;User=YourUsername;Password=YourPassword;UserKey=YourUserKey;"); MyProspectsDAO dao = dbi.open(MyProspectsDAO.class); //do stuff with the DAO dao.close();

Read Salesforce Pardot Data

With the connection open to Salesforce Pardot, simply call the previously defined method to retrieve data from the Prospects entity in Salesforce Pardot.

//disply the result of our 'find' method String email = dao.findEmailByProspectAccountId("703"); System.out.println(email);

Write Salesforce Pardot Data

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

//add a new entry to the Prospects entity dao.insert(newProspectAccountId, newEmail);

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