We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →Create a Data Access Object for PayPal Data using JDBI
A brief overview of creating a SQL Object API for PayPal 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 PayPal integrates connectivity to live PayPal data in Java applications. By pairing these technologies, you gain simple, programmatic access to PayPal data. This article walks through building a basic Data Access Object (DAO) and the accompanying code to read PayPal data.
Create a DAO for the PayPal Transactions 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 MyTransactionsDAO {
//request specific data from PayPal (String type is used for simplicity)
@SqlQuery("SELECT GrossAmount FROM Transactions WHERE TransactionClass = :transactionClass")
String findGrossAmountByTransactionClass(@Bind("transactionClass") String transactionClass);
/*
* close with no args is used to close the connection
*/
void close();
}
Open a Connection to PayPal
Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to PayPal.
The provider surfaces tables from two PayPal APIs. The APIs use different authentication methods.
- The REST API uses the OAuth standard. To authenticate to the REST API, set the OAuthClientId, OAuthClientSecret, and CallbackURL properties.
- The Classic API requires Signature API credentials. To authenticate to the Classic API, obtain an API username, password, and signature.
See the "Getting Started" chapter of the help documentation for a guide to obtaining the necessary API credentials.
To select the API you want to work with, you can set the Schema property to REST or SOAP. By default the SOAP schema will be used.
For testing purposes you can set UseSandbox to true and use sandbox credentials.
Built-in Connection String Designer
For assistance in constructing the JDBC URL, use the connection string designer built into the PayPal JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.paypal.jar
Fill in the connection properties and copy the connection string to the clipboard.

A connection string for PayPal will typically look like the following:
jdbc:paypal:Schema=SOAP;Username=sandbox-facilitator_api1.test.com;Password=xyz123;Signature=zx2127;InitiateOAuth=GETANDREFRESH
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:paypal:Schema=SOAP;Username=sandbox-facilitator_api1.test.com;Password=xyz123;Signature=zx2127;InitiateOAuth=GETANDREFRESH");
MyTransactionsDAO dao = dbi.open(MyTransactionsDAO.class);
//do stuff with the DAO
dao.close();
Read PayPal Data
With the connection open to PayPal, simply call the previously defined method to retrieve data from the Transactions entity in PayPal.
//disply the result of our 'find' method
String grossAmount = dao.findGrossAmountByTransactionClass("Received");
System.out.println(grossAmount);
Since the JDBI library is able to work with JDBC connections, you can easily produce a SQL Object API for PayPal by integrating with the CData JDBC Driver for PayPal. Download a free trial and work with live PayPal data in custom Java applications today.