-
Create a service instance for the HDI container, using the
cf create-service
command.cf create-service hana hdi-shared my-hdi-container
-
Bind the service instance to a Java application.
Specify the service instance in the Java application's deployment manifest file.
manifest.yml
services: - my-hdi-container
-
Add the resource reference to the
web.xml
file, which must have the name of the service instance.web.xml
<resource-ref> <res-ref-name>jdbc/my-hdi-container</res-ref-name> <res-type>javax.sql.DataSource</res-type> </resource-ref>
-
Look up the data source in your code.
You can find the reference to the data source in the following ways:
-
Annotations
@Resource(name = "jdbc/my-hdi-container") private DataSource ds;
-
Java Naming and Directory Interface (JNDI) look-up
Context ctx = new InitialContext(); return (DataSource) ctx.lookup("java:comp/env/jdbc/my-hdi-container");
-