Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (25 sloc) 1.4 KB

Demo: JPA (Java Persistence API)

The articles service stores articles in memory by default. Alternatively SQL databases can be used via JPA. The sample shows how to use the 'Db2 on Cloud' service on the IBM Cloud.

Before running the scripts below, make sure you can access the IBM Cloud. In local.env you also need to define your Cloud Foundry configuration: IBM_CLOUD_CF_ORG, IBM_CLOUD_CF_SPACE and IBM_CLOUD_CF_API.

Create new Db2 service instance

Run the following command to create the 'Db2 on Cloud' service instance:

$ ibm-scripts/

Set up the Demo

Invoke the following commands to set up the demo.

$ scripts/
$ scripts/
$ scripts/
$ scripts/

Run the Demo

Open the API Explorer of the Articles Service. You find the URL in the output of '', for example ''.

Enter a new article and invoke the /create endpoint.

Open the console of 'Db2 on Cloud' from the IBM Cloud dashboard and from there the 'Explore' page. The table 'Article' is created automatically.

Here is the one article, you just created:

You can’t perform that action at this time.