Skip to Content
Technical Articles
Author's profile photo Boudhayan Dev

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 1We 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

Create New instance of this service as follows –

Provide 15 characters long password.

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 –

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.

We will use the CF CLI Tool. Documentation for the usage of this tool can be found here – CLI Documentation.

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 –

3.2 Open HANA Cockpit

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) –

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

For System Privileges grant all the privilege –

 

For Package Privilege assign the following privilege –

 

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.

See you in next part.

Cheers.

 

Find the remaining parts here –

  1. Develop the Spring Boot Application (PART 1) – Develop a Spring Boot (Java) application with HANA database on SAP Cloud Platform (Cloud Foundry) – PART 1
  2. Create instance of HANA service (PART 2) – Develop a Spring Boot (Java) application with HANA database on SAP Cloud Platform (Cloud Foundry) – PART 2
  3. Deploy and Test (PART 3) – Develop a Spring Boot (Java) application with HANA database on SAP Cloud Platform (Cloud Foundry) – PART 3

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo James You
      James You

      Hi ,

       

      In our space , we cannot find “HANA Schema and HDI Service” , as following.

       

      We only have “HANA Service” in our marketplace. Do you have any idea about this ? Thanks in advance.

       

      Best regards,

      James You

      Author's profile photo Boudhayan Dev
      Boudhayan Dev
      Blog Post Author

      Hi,

       

      Check your subaccount entitlements. It must be asssigned to your subaccount.

      Author's profile photo Jerry Zhang
      Jerry Zhang

      Hi,

       

      Why I have no Service Plan of schema in the drop down list when creating SAP HANA Schema and HDI Container service instance?

      Thanks,

      Jerry

      Author's profile photo Boudhayan Dev
      Boudhayan Dev
      Blog Post Author

      Schema plan is not available in trial accounts. You need a productive account for that.

      Author's profile photo Jerry Zhang
      Jerry Zhang

      Thank you for your reply.

      To clarify, it is a productive account actually.

      Author's profile photo Boudhayan Dev
      Boudhayan Dev
      Blog Post Author

      In that case, the service plan may not be provisioned for your subaccount. You can add the plan via ISM cockpit.

      Author's profile photo Ameya Suvarna
      Ameya Suvarna

      Hello,

       

      If I want to try this in Cloud Foundry Trial account, how do I assign the required roles, as the dashboard is not available?

       

      Regards,

      Ameya

      Author's profile photo Mirco Roth
      Mirco Roth

      Hi Boudhayan Dev,

      first of all: great guide with a lot of information and well written!

      I know this is a bit offtopic but maybe you can still answer my question.

      Is it possible to use the HANA Service to create multitenant HDI containers for trial account on CF?

      Also: Could you point out what exactly is the difference between schema-plan and HDI-shared?
      I see that HDI uses a schema inside.. but what are the "HANA artefacts" ? Sorry I am not that experienced in programming yet.

      Thank you very much in advance

      Best regards
      Mirco

      Author's profile photo Boudhayan Dev
      Boudhayan Dev
      Blog Post Author

      Hi Mirco Roth

       

      Is it possible to use the HANA Service to create multitenant HDI containers for trial account on CF?

      Yes, I believe that is possible. Also, looks like you now have access to both schema and hdi-shared plan on trial account.

       

      Could you point out what exactly is the difference between schema-plan and HDI-shared?
      I see that HDI uses a schema inside.

       

      Simply put, use hdi-shared with CAP/CDS based data modelling approach (not used in this blog). Use schema plan, when you are using a ORM like Hibernate (used in this blog). You can read more about it here - https://answers.sap.com/questions/12899372/explain-the-difference-between-hdi-shared-schema-p.html

       

      Regards

      Author's profile photo Mirco Roth
      Mirco Roth

      Thank you very much!

      Author's profile photo Maciej Dluzen
      Maciej Dluzen

      Hi

       

      Unfortunately, SAP HANA Service is missing from my Service Marketplace. Only SAP HANA Schema and HDI Container is visible. I use trial account at the moment.

      Could you please give me any advice?

      My service marketplace (filtered to contain only HANA in the title) and subaccount assignments look like below. S/4 Cloud service has set limited quota and I cannot change it.

      Any help will be very much appreciated.

      Regards,

      Maciej

      Author's profile photo Boudhayan Dev
      Boudhayan Dev
      Blog Post Author

      You can skip the Hana step in trial. Go ahead with the schema plan of HDI containers

      Author's profile photo Anil k
      Anil k

       

      Hi Boudhayan Dev,

      Thanks for that post . Trying to build multitenant application with spring boot.

      Not using CDS in my project.

      If i use schema plan, how can make my springboot app switch between multiple schemas based on tenant (assuming one schema per tenant) ?

      does cloud sdk provides any out of the box facility  for this ?

       

      Any help will be  much appreciated.

      Author's profile photo Boudhayan Dev
      Boudhayan Dev
      Blog Post Author

      Maybe you can look into Instance Manager Library/Service. As far as I remember, it touched upon multitenancy support for Java backed apps.