Ready to get started?

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

 Download Now

Learn more:

eBay Analytics Icon eBay Analytics JDBC Driver

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

Create a Data Access Object for eBay Analytics Data using JDBI



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

Create a DAO for the eBay Analytics TrafficReportByListing 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 MyTrafficReportByListingDAO { //request specific data from eBay Analytics (String type is used for simplicity) @SqlQuery("SELECT ClickThroughRate FROM TrafficReportByListing WHERE ListingId = :listingId") String findClickThroughRateByListingId(@Bind("listingId") String listingId); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to eBay Analytics

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

You can authenticate to eBay Analytics only via the OAuth 2 authentication method. The eBay Analytics API requires an access token created with the authorization code grant flow to authorize the requests.

You can follow the guide in the Help documentation for a step by step guide on how to authenticate using the OAuth 2 protocol.

Built-in Connection String Designer

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

java -jar cdata.jdbc.ebayanalytics.jar

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

A connection string for eBay Analytics will typically look like the following:

jdbc:ebayanalytics:OAuthClientId=MyAppID;OAuthClientSecret=MyCertID;RuName=MyRuName;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:ebayanalytics:OAuthClientId=MyAppID;OAuthClientSecret=MyCertID;RuName=MyRuName;InitiateOAuth=GETANDREFRESH"); MyTrafficReportByListingDAO dao = dbi.open(MyTrafficReportByListingDAO.class); //do stuff with the DAO dao.close();

Read eBay Analytics Data

With the connection open to eBay Analytics, simply call the previously defined method to retrieve data from the TrafficReportByListing entity in eBay Analytics.

//disply the result of our 'find' method String clickThroughRate = dao.findClickThroughRateByListingId("201284405428"); System.out.println(clickThroughRate);

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