Ready to get started?

Learn more about the CData JDBC Driver for EDGAR Online or download a free trial:

Download Now

Create a Data Access Object for EDGAR Online Data using JDBI

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

Create a DAO for the EDGAR Online Subscriptions 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 MySubscriptionsDAO { //insert new data into EDGAR Online @SqlUpdate("INSERT INTO Subscriptions (SubscriberEmail, Name) values (:subscriberEmail, :name)") void insert(@Bind("subscriberEmail") String subscriberEmail, @Bind("name") String name); //request specific data from EDGAR Online (String type is used for simplicity) @SqlQuery("SELECT Name FROM Subscriptions WHERE SubscriberEmail = :subscriberEmail") String findNameBySubscriberEmail(@Bind("subscriberEmail") String subscriberEmail); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to EDGAR Online

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to EDGAR Online.

  1. Navigate to https://developer.edgar-online.com/ and create an account.
  2. Register a new application and retrieve the AppKey. You should select one of the available Web APIs this application will use like HackPack, Insider Trades or Institutional Ownership.
    Note: HackPack is the most important Web API that an application can use since it supports a large number of endpoints. If you are getting the "Access Denied" error you must create a new app and select the correct Web API which supports the resource you are querying.
  3. After successfully creating a new app, you can access your keys through your "my account" area. Set the AppKey connection property value equal to the Key of your application.

Built-in Connection String Designer

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

java -jar cdata.jdbc.edgaronline.jar

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

A connection string for EDGAR Online will typically look like the following:

jdbc:edgaronline:AppKey=20dd8ce9904d422ed89ebde1ad40d

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:edgaronline:AppKey=20dd8ce9904d422ed89ebde1ad40d"); MySubscriptionsDAO dao = dbi.open(MySubscriptionsDAO.class); //do stuff with the DAO dao.close();

Read EDGAR Online Data

With the connection open to EDGAR Online, simply call the previously defined method to retrieve data from the Subscriptions entity in EDGAR Online.

//disply the result of our 'find' method String name = dao.findNameBySubscriberEmail("user@domain.com"); System.out.println(name);

Write EDGAR Online Data

It is also simple to write data to EDGAR Online, using the previously defined method.

//add a new entry to the Subscriptions entity dao.insert(newSubscriberEmail, newName);

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