Ready to get started?

Learn more about CData API Server or sign up for a free trial:

Learn More

Integrate Real-Time Access to Redshift in SAPUI5 MVC Apps

Use the built-in ODataModel class in SAPUI5 to create Web apps that reflect changes to Redshift data in real time.

In this article we show how to use the CData API Server and with the ADO.NET Provider for Redshift (or any of 130+ other ADO.NET Providers) to write SAPUI5 apps that leverage the capabilities of the Redshift API, without writing to a back-end database. The API Server is a lightweight Web application that runs on your server and produces OData feeds of Redshift data. OData is the standard for real-time data access over the Web and has built-in support in SAPUI5 and OpenUI5.

Set Up the API Server

Follow the steps below to begin producing secure Redshift OData services:


The API Server runs on your own server. On Windows, you can deploy using the stand-alone server or IIS. On a Java servlet container, drop in the API Server WAR file. See the help documentation for more information and how-tos.

The API Server is also easy to deploy on Microsoft Azure, Amazon EC2, and Heroku.

Connect to Redshift

After you deploy the API Server and the ADO.NET Provider for Redshift, provide authentication values and other connection properties needed to connect to Redshift by clicking Settings -> Connections and adding a new connection in the API Server administration console.

To connect to Redshift, set the following:

  • Server: Set this to the host name or IP address of the cluster hosting the Database you want to connect to.
  • Port: Set this to the port of the cluster.
  • Database: Set this to the name of the database. Or, leave this blank to use the default database of the authenticated user.
  • User: Set this to the username you want to use to authenticate to the Server.
  • Password: Set this to the password you want to use to authenticate to the Server.

You can obtain the Server and Port values in the AWS Management Console:

  1. Open the Amazon Redshift console (
  2. On the Clusters page, click the name of the cluster.
  3. On the Configuration tab for the cluster, copy the cluster URL from the connection strings displayed.

You can then choose the Redshift entities you want to allow the API Server access to by clicking Settings -> Resources. This article uses Orders as an example.

Authorize API Server Users

After determining the OData services you want to produce, authorize users by clicking Settings -> Users. The API Server uses authtoken-based authentication and supports the major authentication schemes. You can authenticate as well as encrypt connections with SSL. Access can also be restricted by IP address; Access is restricted to only the local machine by default.

Create the View

In this article the user views and interacts with Redshift data through an SAPUI5 table control. Table columns will be automatically detected from the metadata retrieved from the API Server's API endpoint. We define the following table in a separate View.view.xml file:

          path: 'meta>/dataServices/schema/[${namespace}===\'CData\']/entityType/[${name}===\'Orders\']/property',
          factory: '.columnFactory'
            <m:Title text="Redshift Orders"></m:Title>
          <m:BusyIndicator class="sapUiMediumMargin"/>

Create the Model and Controller

In SAPUI5, you do not need to write any OData queries; an ODataModel instance handles the application's data access commands. The API Server then translates the queries into Redshift API calls.

The controller processes user input and represents information to the user through a view. Define the controller in a new file, Controller.controller.js. Instantiate the model in the onInit function -- you will need to replace the placeholder values for the URL to the API Server, a user allowed to access the OData endpoint of the API Server, and the authtoken for the user.

], function(Controller, ODataModel, JSONModel, Column, Text ) {
  "use strict";

  return Controller.extend("sap.ui.table.sample.OData2.Controller", {
    onInit : function () {
      var oView = this.getView();
      var oDataModel = new ODataModel("http://myserver/api.rsc/",{user: "MyUser", password: "MyAuthToken"});
        oView.setModel(oDataModel.getMetaModel(), "meta");
      var oTable = oView.byId("table");
      var oBinding = oTable.getBinding("rows");
      var oBusyIndicator = oTable.getNoData();
        oTable.setNoData(null); //use default again ("no data" in case no data is available)
    onExit : function () {
    columnFactory : function(sId, oContext) {
      var oModel = this.getView().getModel();
      var sName = oContext.getProperty("name");
      var sType = oContext.getProperty("type");
      var iLen = oContext.getProperty("maxLength");
      iLen = iLen ? parseInt(iLen, 10) : 10;
      return new Column(sId, {
        sortProperty: sName, 
        filterProperty: sName,
        width: (iLen > 9 ? (iLen > 50 ? 15 : 10) : 5) + "rem",
        label: new sap.m.Label({text: "{/#Orders/" + sName + "/@name}"}),
        hAlign: sType && sType.indexOf("Decimal") >= 0 ? "End" : "Begin",
        template: new Text({text: {path: sName}})


Describe Application Logic

Create a component that contains the resources of your application. Define the following in Component.js:

], function(UIComponent) {
  "use strict";

  return UIComponent.extend("sap.ui.table.sample.OData2.Component", {
    metadata : {
      rootView : "sap.ui.table.sample.OData2.View",
      dependencies : {
        libs : [

      config : {
        sample : {
          stretch : true,
          files : [


Bootstrap OpenUI5 and Launch

To complete the MVC application, simply add the bootstrap and initialization code. Add these directly to index.html:


  <meta http-equiv="x-ua-compatible" content="ie=edge" />
  <meta charset="utf-8"> 
  <title>Redshift Orders</title>
  <script id="sap-ui-bootstrap"
    data-sap-ui-resourceroots='{"sap.ui.table.sample.OData2": "./", "sap.ui.demo.mock": "mockdata"}'>
  <!-- application launch configuration -->
      sap.ui.getCore().attachInit(function() {
        new sap.m.App ({
          pages: [
                new sap.m.Page({
                    title: "Redshift Orders", 
                    enableScrolling : false,
                  content: [ new sap.ui.core.ComponentContainer({
                  height : "100%", name : "sap.ui.table.sample.OData2"

  <!-- UI Content -->
<body class="sapUiBody" id="content" role="application">

The resulting SAPUI5 table control reflects any changes to a table in the remote Redshift data. You can now browse and search current Redshift data.