-
Create a
context.xml
file.This file has to be inside the
META_INF/
folder of the application WAR file, and has to contain information about the data source to be used.context.xml
<?xml version='1.0' encoding='utf-8'?> <Context> <Resource name="jdbc/DefaultDB" auth="Container" type="javax.sql.DataSource" factory="com.sap.xs.jdbc.datasource.tomcat.TomcatDataSourceFactory" service="${service_name_for_DefaultDB}"/> </Context>
-
Add the default keys and their values. You need to include the data source information in directory
META-INF/sap_java_buildpack/config/resource_configuration.yml
of the WAR file.Define a default service name:
resource_configuration.yml
--- tomcat/webapps/ROOT/META-INF/context.xml: service_name_for_DefaultDB: di-core-hdi
-
Add the key values to be updated. You need to include the data source information to be updated in the
manifest.yml
file.Define the new service name for the look-up of the data source:
manifest.yml
env: JBP_CONFIG_RESOURCE_CONFIGURATION: "['tomcat/webapps/ROOT/META-INF/context.xml': {'service_name_for_DefaultDB' : 'my-local-core-hdi'}]"
When the application starts, the factory named com.sap.xs.jdbc.datasource.TomcatDataSourceFactory
takes the parameters bound for service my-local-core-hdi from the environment, creates a data source, and binds it under jdbc/DefaultDB
. The application then uses the Java Naming and Directory Interface (JNDI) to look up how to connect with the database.
Related Information