Ready to get started?

Download a free trial of the Power BI XMLA Driver to get started:

 Download Now

Learn more:

Power BI XMLA Icon Power BI XMLA JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Power BI XMLA.

Create a Data Access Object for Power BI XMLA Data using JDBI



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

Create a DAO for the Power BI XMLA Customer 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 MyCustomerDAO { //request specific data from Power BI XMLA (String type is used for simplicity) @SqlQuery("SELECT Education FROM Customer WHERE Country = :country") String findEducationByCountry(@Bind("country") String country); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Power BI XMLA

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Power BI XMLA.

By default, use Azure AD to connect to Microsoft Power BI XMLA. Azure AD is Microsoft’s multi-tenant, cloud-based directory and identity management service. It is user-based authentication that requires that you set AuthScheme to AzureAD.

For more information on other authentication schemes, refer to the Help documentation.

Built-in Connection String Designer

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

java -jar cdata.jdbc.powerbixmla.jar

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

A connection string for Power BI XMLA will typically look like the following:

jdbc:powerbixmla:AuthScheme=AzureADInitiateOAuth=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:powerbixmla:AuthScheme=AzureADInitiateOAuth=GETANDREFRESH"); MyCustomerDAO dao = dbi.open(MyCustomerDAO.class); //do stuff with the DAO dao.close();

Read Power BI XMLA Data

With the connection open to Power BI XMLA, simply call the previously defined method to retrieve data from the Customer entity in Power BI XMLA.

//disply the result of our 'find' method String education = dao.findEducationByCountry("Australia"); System.out.println(education);

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