Create a Data Access Object for AWS Management Data using JDBI

Ready to get started?

Download for a free trial:

Download Now

Learn more:

AWS Management JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with live AWS Management data!

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

Create a DAO for the AWS Management NorthwingProducts 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 MyNorthwingProductsDAO { //insert new data into AWS Management @SqlUpdate("INSERT INTO NorthwingProducts (Id, Name) values (:id, :name)") void insert(@Bind("id") String id, @Bind("name") String name); //request specific data from AWS Management (String type is used for simplicity) @SqlQuery("SELECT Name FROM NorthwingProducts WHERE Id = :id") String findNameById(@Bind("id") String id); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to AWS Management

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to AWS Management.

To authorize AWSDataManagement requests, provide the credentials for an administrator account or for an IAM user with custom permissions:

  1. Set AccessKey to the access key Id.
  2. Set SecretKey to the secret access key.
  3. Set Region to the region where your AWSDataManagement data is hosted.

Note: Though you can connect as the AWS account administrator, it is recommended to use IAM user credentials to access AWS services.

Built-in Connection String Designer

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

java -jar cdata.jdbc.awsdatamanagement.jar

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

A connection string for AWS Management 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:awsdatamanagement:AccessKey=myAccessKey;Account=myAccountName;Region=us-east-1;"); MyNorthwingProductsDAO dao =; //do stuff with the DAO dao.close();

Read AWS Management Data

With the connection open to AWS Management, simply call the previously defined method to retrieve data from the NorthwingProducts entity in AWS Management.

//disply the result of our 'find' method String name = dao.findNameById("1"); System.out.println(name);

Write AWS Management Data

It is also simple to write data to AWS Management, using the previously defined method.

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

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