<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: CAP Java: How to connect to PostgreSQL on BTP from BAS in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14023426#M4904467</link>
    <description>@mioYasutuke: Were you able to connect from BAS to Postgre SQL DB and also fetch data via app itself? Or is it only possible to fetch data from local postGre? Our assumption is that after deployment to BTP and via app router link to app, to fetch PostgreDB data. In BAS, we get ResourceTimedOut issue, when requesting the endpoints.</description>
    <pubDate>Fri, 21 Feb 2025 08:53:51 GMT</pubDate>
    <dc:creator>rgadirov</dc:creator>
    <dc:date>2025-02-21T08:53:51Z</dc:date>
    <item>
      <title>CAP Java: How to connect to PostgreSQL on BTP from BAS</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaq-p/14003400</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;I have developed a CAP Java project utilizing PostgreSQL on BTP as the database. After successfully deploying it, I now want to connect to the PostgreSQL instance on BTP from BAS for hybrid testing.&lt;/P&gt;&lt;P&gt;I have done the following setting, but running the service results in the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;java.lang.IllegalArgumentException: Could not resolve placeholder 'vcap.services.cap-java-postgresql.credentials.hostname' in value "jdbc:postgresql://${vcap.services.cap-java-postgresql.credentials.hostname}...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has experience with hybrid testing of PostgreSQL in CAP Java, I would appreciate your insights.&lt;/P&gt;&lt;P&gt;The source code is available on&amp;nbsp;&lt;A href="https://github.com/miyasuta/cap-java-postgresql" target="_self"&gt;GitHub&lt;/A&gt;.&lt;/P&gt;&lt;H3&gt;Steps&lt;/H3&gt;&lt;P&gt;1. Bind the PostgreSQL instance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;cds bind db --to cap-java-postgresql-postgres&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Add the following settings to &lt;STRONG&gt;application.yaml&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="yaml"&gt;---
spring:
  config.activate.on-profile: hybrid
  datasource:
      driver-class-name: org.postgresql.Driver
      url: jdbc:postgresql://${vcap.services.cap-java-postgresql-postgres.credentials.hostname}:${vcap.services.cap-java-postgresql-postgres.credentials.port}/${vcap.services.cap-java-postgresql-postgres.credentials.dbname}
      username: ${vcap.services.cap-java-postgresql-postgres.credentials.username}
      password: ${vcap.services.cap-java-postgresql-postgres.credentials.password}    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* The same settings are applied for the cloud profile.&lt;/P&gt;&lt;P&gt;3. Run the service in hybrid mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;cds bind --exec -- mvn spring-boot:run \
  -Dspring-boot.run.profiles=default,hybrid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also confirmed that the VCAP_SERVICES environment variables were set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;cds bind --exec -- node -e 'console.log(process.env.VCAP_SERVICES)'

resolving cloud service bindings...
getting service key cap-java-postgresql-postgres-key
bound db to Cloud Foundry managed service cap-java-postgresql-postgres:cap-java-postgresql-postgres-key
{"postgresql-db":[{"label":"postgresql-db","plan":"trial","tags":["relational","database"],"name":"db","credentials":{"username":"username","password":"password","hostname":"postgres-6fca9245-35fc-4563-ad40-fc42eda9ec92.cqryblsdrbcs.us-east-1.rds.amazonaws.com","dbname":"LiSLQFtKWKQF","port":"4828","uri":"postgres://df85ecbde5ce:f6a265537c8d82879a8@postgres-6fca9245-35fc-4563-ad40-fc42eda9ec92.cqryblsdrbcs.us-east-1.rds.amazonaws.com:4828/LiSLQFtKWKQF","urls":{"api_server":"https://api-backing-services.us10-001.data.services.cloud.sap"},"sslcert":" ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 21:04:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaq-p/14003400</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2025-01-31T21:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java: How to connect to PostgreSQL on BTP from BAS</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14003736#M4901517</link>
      <description>&lt;P&gt;Postgres DB (from BTP) host is not accessible from public internet, not also from BAS. It is only accessible from the subaccount where it is subscribed. So you have to create a tunnel to a running CF application to access it and reconfigure access to the DB to use localhost on the port where the tunnel is opened. The setup is same as mentioned in the documentation, note step 4 in&amp;nbsp;&lt;A href="https://help.sap.com/docs/postgresql-hyperscaler-option/postgresql-on-sap-btp-hyperscaler-option/export-data-from-postgresql-service-instance?locale=en-US" target="_blank" rel="noopener"&gt;Export Data from PostgreSQL Service Instance.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are some conveniences for nodeJS: &lt;A href="https://cap.cloud.sap/docs/advanced/hybrid-testing#overwriting-service-credentials" target="_blank" rel="noopener"&gt;Overwrite Cloud Service Credentials&lt;/A&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2025 20:06:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14003736#M4901517</guid>
      <dc:creator>Dinu</dc:creator>
      <dc:date>2025-02-01T20:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java: How to connect to PostgreSQL on BTP from BAS</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14005941#M4901856</link>
      <description>&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/158770"&gt;@Dinu&lt;/a&gt; Thank you very much for your prompt reply. I was able to connect to the PostgreSQL instance from BAS using the method you suggested.</description>
      <pubDate>Mon, 03 Feb 2025 20:14:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14005941#M4901856</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2025-02-03T20:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java: How to connect to PostgreSQL on BTP from BAS</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14023426#M4904467</link>
      <description>@mioYasutuke: Were you able to connect from BAS to Postgre SQL DB and also fetch data via app itself? Or is it only possible to fetch data from local postGre? Our assumption is that after deployment to BTP and via app router link to app, to fetch PostgreDB data. In BAS, we get ResourceTimedOut issue, when requesting the endpoints.</description>
      <pubDate>Fri, 21 Feb 2025 08:53:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14023426#M4904467</guid>
      <dc:creator>rgadirov</dc:creator>
      <dc:date>2025-02-21T08:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: CAP Java: How to connect to PostgreSQL on BTP from BAS</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14038689#M4906240</link>
      <description>&lt;P&gt;Yes, I was able to connect to PostgreSQL from BAS. I have described the procedure in my blog post (in Japanese ) below: &lt;A href="https://qiita.com/tami/items/bc6f6aacf96c959b35a1#%E3%83%8F%E3%82%A4%E3%83%96%E3%83%AA%E3%83%83%E3%83%89%E5%AE%9F%E8%A1%8C" target="_blank" rel="noopener"&gt;https://qiita.com/tami/items/bc6f6aacf96c959b35a1#%E3%83%8F%E3%82%A4%E3%83%96%E3%83%AA%E3%83%83%E3%83%89%E5%AE%9F%E8%A1%8C&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 09:48:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-java-how-to-connect-to-postgresql-on-btp-from-bas/qaa-p/14038689#M4906240</guid>
      <dc:creator>MioYasutake</dc:creator>
      <dc:date>2025-03-10T09:48:49Z</dc:date>
    </item>
  </channel>
</rss>

