Aside from initializing the SAP HANA database, the cds deploy
command created a file with the name default-env.json
in your bookstore
root folder. This file contains a set of credentials to connect to the SAP HANA HDI container, that was created by the command. CAP Java is able to automatically pick up the SAP HANA credentials from this file and configure the application running locally to use the SAP HANA HDI container as the database.
When deploying the application to the cloud, Cloud Foundry will provide the credentials as a service binding to the application through the Open Service Broker API. Also in this case, CAP Java will automatically pick up the SAP HANA credentials and configures the application for you as you will see in the next tutorial.
Before starting your application, make sure that you stop any running instances in the terminal or debug side panel.
Let’s test the SAP HANA connectivity. Start your application by running:
mvn spring-boot:run -Dspring-boot.run.profiles=cloud
The Java system property -Dspring-boot.run.profiles=cloud
ensures that the default configuration using H2 as the database, which is still defined in the application.yaml
, doesn’t get activated.
You can observe the log line Registered DataSource 'bookstore-hana'
, which indicate that the SAP HANA configuration was picked up.
Open the file requests.http
and execute one of the requests that create an order, by choosing Send Request above it.
Restart your application with the same command and browse to the Orders
entity on the Welcome Page. You can see that the entries are persisted.
Congratulations!
You have successfully deployed your database schema to SAP HANA and connected your application, which is running locally. In the following tutorial, you will run the application on the SAP BTP, Cloud Foundry environment, using the SAP HANA service instance that was created in this tutorial.