Skip to Content
Technical Articles

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

We will continue from where we left off in the previous part  where we finished configuring the HANA Database and the user that will communicate with the database.

STEP 4: Deploy the Application

Let’s build the war file first. If you are using Eclipse, then perform a maven build and specify profile as cf.  Otherwise, you can also build the application using maven command line tool with the following command –

mvn clean install -P cf

Let’s push the application to cloud foundry space now.To deploy the application, execute the following command from project root –

cf push

If everything goes alright, you should have your application deployed in Cloud Foundry. You can check the status of the application using –

cf app spring-hana-cloud-foundry


Yay ! The application is deployed. You can try out the endpoints as follows –

  1. GET <APP-ROOT>/employee/count -> Returns count of total employees in database.
  2. GET <APP-ROOT>/employee/all -> Returns all employees in database.
  3. GET <APP-ROOT>/employee/id/{id} -> Returns the employee instance corresponding to the ID.
  4. POST <APP-ROOT>/employee/add -> Add a new employee in database. Use the following payload in body –
  5. DELETE <APP-ROOT>/employee/delete/{id} -> Delete particular employee from database.


STEP 5: Check Database content.

Execute few POST requests as listed above to insert some items in the database. We will now check the database with the Database user to see those records –

Launch SAP HANA Cockpit with the Database user –

If you are still logged on with the SYSTEM user, try logging out by clicking Clear Credentials. This would prompt you to enter credentials. Use the credentials found in the service key that we created earlier in step 3.

Once logged in, click Open SQL Console. This will open the database explorer where you can check the database artifacts created by this user –

As you can see, the table – EMPLOYEE exists for the database user. If you open the contents of this data, you’ll find the records that were inserted.


I have inserted 3 records earlier, which can be seen in the database above. We have successfully, bound HANA DB to our application in SAP Cloud Platform (CF).

This completes the 3 part blog series where we saw how to create a Spring Boot Application and bind it t HANA database. In case of any doubts or queries, do leave out your message. I’ll be happy to help.

All the best !



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
You must be Logged on to comment or reply to a post.
  • Hello Boudhayan Dev,


    This is a fantastic blog! Thanks for this.

    However, I tried the exact same project using your own code. I have deployed on my trial account of cloud foundry using HDI-Shared plan.

    And when I run any service, I'm getting the below error (Example of /employee/count)

    "could not prepare statement; SQL [select count(*) as col_0_0_ from employee employee0_]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement",

    It looks like the hibernate dialect for HANA is having trouble generating SQL. Please help in resolving this.

    BTW, I used a new version of HANA driver dependency (not the one you have mentioned in the blog)





    • Hello Chaithanya Mirle Kantharaju ,


      You need to use the schema plan of the HDI Service.

      The error is because hibernate could not create a connection with the database in the first place. Schema plan is not available in Trial landscape as far as i know.


      Boudhayan Dev

      • Hello,

        Ah ok. So there is no way to deploy a Spring JPA with this dialect on trial account then?

        Can you explain why do you need a schema plan only? even HDI shared also internally creates a schema for my user but on a shared db isn't it?




        • Well Yes, HDI shared creates a schema as well but from what I gathered during my research with this topic is that hdi-shared creates a container for deploying CDS artifacts. As such, it  is to be used for CDS based database modelling projects.

          And schema plan for direct binding to applications - similar to PostGres, MySQL schemas. Ill try linking the article if I find it. Meanwhile, you can try the live/canary acc if you have access to.

  • Hi,

    Great Blog, I was following your blog and i followed exactly whatever you have mentioned in the Cloud foundry Spring boot app with the hibernate , when i push my code the CF i am getting the following error in the app logs


    i am using the hana trial account..


    Caused by: SAP DBTech JDBC: [258]: insufficient privilege: Detailed info for this error can be found with guid ’21FDA09352F3474A8E9760CF6C4034BA’

    even i tried granting the select insert update delete permission on the table from sap web ide  data base explorer but still it is throwing the same error, Please help


    Any help would be great.





        • It will not work. I have mentioned this in the blog.

          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.

          • But in the comments i can see it worked for Chaithanya Mirle Kantharaju by creating table manually.

            So i tried by that as well, and it still throws the same error.


            Anyways thank you so much for the valuable reply, i will try using the schema plan and check .


            Thank you,