Skip to content
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions guides/databases-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,39 @@ Output:

## Provisioning a DB Instance

To connect to a PostgreSQL offering from the cloud provider in Production, leverage the [PostgreSQL on SAP BTP, hyperscaler option](https://discovery-center.cloud.sap/serviceCatalog/postgresql-hyperscaler-option).
To connect to a PostgreSQL offering from the cloud provider in Production, leverage the [PostgreSQL on SAP BTP, hyperscaler option](https://discovery-center.cloud.sap/serviceCatalog/postgresql-hyperscaler-option). For local development and testing convenience, you can run PostgreSQL in a [docker container](#using-docker).


<div markdown="1" class="impl java">

To consume a PostgreSQL instance from a CAP Java application running on SAP BTP, consider the following:

- Only the Java buildpack `java_buildpack` provided by the Cloud Foundry community allows to consume a PostgreSQL service from a CAP Java application.

- By default, the `java_buildpack` initializes a PostgreSQL datasource with the Java CFEnv library. However, to work properly with CAP, the PostgreSQL datasource must be created by the CAP Java runtime and not by the buildpack. You need to disable the [datasource initialization by the buildback](https://docs.cloudfoundry.org/buildpacks/java/configuring-service-connections.html) using `CFENV_SERVICE_<POSTGRESQL_SERVICE_NAME>_ENABLED: false` at your CAP Java service module.

The following example shows these configuration settings applied to a CAP Java service:

::: code-group
```yaml [mta.yaml]
modules:
- name: bookshop-pg-srv
type: java
path: srv
parameters:
buildpack: java_buildpack
properties:
SPRING_PROFILES_ACTIVE: cloud
JBP_CONFIG_COMPONENTS: '{jres: ["JavaBuildpack::Jre::SapMachineJRE"]}'
JBP_CONFIG_SAP_MACHINE_JRE: '{ jre: { version: "17.+" } }'
CFENV_SERVICE_BOOKSHOP-PG-DB_ENABLED: false
```

:::

> `BOOKSHOP-PG-DB` is the real PostgreSQL service instance name in this example.
</div>

For local development and testing convenience, you can run PostgreSQL in a [docker container](#using-docker).

### Using Docker

Expand Down