Create a Data Access Object for SAP BusinessObjects BI Data using JDBI

Ready to get started?

Download for a free trial:

Download Now

Learn more:

SAP BusinessObjects BI JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with SAP BusinessObjects BI.



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

Create a DAO for the SAP BusinessObjects BI MyCustomReport 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 MyMyCustomReportDAO { //request specific data from SAP BusinessObjects BI (String type is used for simplicity) @SqlQuery("SELECT TotalRevenue FROM MyCustomReport WHERE State = :state") String findTotalRevenueByState(@Bind("state") String state); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to SAP BusinessObjects BI

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to SAP BusinessObjects BI.

To connect to your SAP Business Objects BI instance, you must set the following connection properties:

  • Url: set this to the rest API URL. After logging into the Central Management Console, choose 'Applications' from the combo box. Double-click on 'RESTful Web Service' and you'll see the access URL. By default it is, http://{Server-Name}:6405/biprws.
  • User: set this to the username of your instance.
  • Password: set this to the password of your instance.

Built-in Connection String Designer

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

java -jar cdata.jdbc.sapbusinessobjectsbi.jar

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

A connection string for SAP BusinessObjects BI will typically look like the following:

jdbc:sapbusinessobjectsbi:User=username;Password=password;Url=http://myinstance:6405/biprws

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:sapbusinessobjectsbi:User=username;Password=password;Url=http://myinstance:6405/biprws"); MyMyCustomReportDAO dao = dbi.open(MyMyCustomReportDAO.class); //do stuff with the DAO dao.close();

Read SAP BusinessObjects BI Data

With the connection open to SAP BusinessObjects BI, simply call the previously defined method to retrieve data from the MyCustomReport entity in SAP BusinessObjects BI.

//disply the result of our 'find' method String totalRevenue = dao.findTotalRevenueByState("CA"); System.out.println(totalRevenue);

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