Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
boudhayan-dev
Employee
Employee
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 –
    {
    "id":"1",
    "firstName":"Boudhayan",
    "lastName":"Dev",
    "email":"email@example.com",
    "contact":"12121212"
    }


  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 !

Thanks

 

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

  2. Create instance of HANA service (PART 2) - Develop a Spring Boot (Java) application with HANA database on SAP Cloud Platform (Cloud Foundry) - ...

  3. Deploy and Test (PART 3) - Develop a Spring Boot (Java) application with HANA database on SAP Cloud Platform (Cloud Foundry) – ...

17 Comments