Wednesday 7 August 2019

Develop a Spring Boot (Java) application with HANA database on SAP Cloud Platform (Cloud Foundry) – PART 2

In this blog post, we continue with the Spring Boot application that we developed in PART 1. We will now look at the steps involved in binding a HANA instance with our application.

STEP 2 : Create HANA service instance.


We will create the HANA service instance in this step. HANA service provisions a HANA DB for us. This is a paid service so you’ll need to enable it using ISM tool.

For this exercise, we will use the 64standard service plan.

Navigate to Service Marketplace of your CF space and select SAP HANA Service –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

Create New instance of this service as follows –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

Provide 15 characters long password.

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

You can skip the next step, as the binding is not really required. Confirm the creation of service by giving it a name – haas.

STEP 3 : Create SAP HANA Schema and HDI Container service instance.


Now that we have provisioned a HANA DB for us, it is time to create an instance of HANA Schema and HDI Service. This service generates a schema (if you use schema plan) which allows your Spring Boot application to create its database artifacts. There are other plans ofcourse which cater to different use-cases. For example, if you follow the Cloud Application Programming model, it is recommended to model the database artifacts in CDS. In that case, hdi-shared plan is used, which deploys the database artifacts from your CDS files.

However, in this exercise we will make use of the schema plan, as our database tables are defined in the application layer itself.

Navigate to Cloud Foundry space and create an instance of SAP HANA Schema and HDI Container service as follows –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

You can leave the application binding for now as the binding will take place during application deployment. We will name the instance as hana_migration.

STEP 3 : Assign Roles and permissions for the HDI user.


Now that you have created a HDI schema service, it would have generated an database user for you. We need to assign roles and permissions to this user so that our application can use this user to create the database artifacts.

Let us create a service key for the hana_migration service instance.

cf csk hana_migration hanaKey
cf service-key hana_migration hanaKey

This will generate service key as follows –

{
 "certificate": "-----BEGIN CERTIFICATE-----",
 "driver": "com.sap.db.jdbc.Driver",
 "host": "zeus.hana...",
 "password": "...",
 "port": "2...",
 "schema": "U...",
 "url": "jdbc:sap://...",
 "user": "U..."
}

We will grant Roles and Permission to this user.

3.1 Open the dashboard for the HANA Service instance.

Open the dashboard for the HANA service instance that we created earlier –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

3.2 Open HANA Cockpit

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

The HANA Cockpit opens up with the SYSTEM user that we created while instantiating an instance of SAP HANA Service.Navigate to Role Management and assign the following roles to the user (found int the service key above) –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

And finally, we need to grant the package privilege to the user. Navigate to Privilege Assignment –

For System Privileges grant all the privilege –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

For Package Privilege assign the following privilege –

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

SAP HANA Tutorial and Material, SAP HANA Certifications, SAP HANA Guides, SAP HANA Online Exam, SAP HANA Database

With this we have everything in place to deploy the application.  In the next and final part of the blog series, we will deploy our application to Cloud Foundry and check the contents of the database.

No comments:

Post a Comment