Search code examples
databasedb2ibm-cloud

Bluemix Local: How do I add an existing on-prem DB2 database as service?


I am using Bluemix Local and have an existing on-premises database (DB2 LUW) that I want to use with a Cloud Foundry application. How can I make that database "testDB" available as a service, so that my app can use the VCAP_SERVICES variable to access that database?

Do I need a custom broker or will an user-provided service do the trick?

cf cups db2-testdb only adds a service, but no JDBC properties.


Solution

  • The user-provided service is the right choice to make any existing on-premises database, DB2 in your case, available for a Cloud Foundry app on Bluemix Local (actually any Cloud Foundry instance).

    1. Log in to Bluemix/Cloud Foundry
    2. Create the user-provided service
    3. Bind the service to an app

    You can also update the properties of an user-provided service.

    To specify properties during creation use: cf cups db2-testdb -p '{"jdbcURL" : "jdbc:db2://yourMachine.com:50000/TESTDB"}'

    To later on change properties (update-user-provided-service): cf uups db2-testdb -p '{"jdbcURL" : "jdbc:db2://yourMachine2.com:40000/TESTDB02"}'

    To bind the service to an app use either the GUI or the following command: cf bind-service yourAppName db2-testdb Your app would then be able to find the service via the VCAP_SERVICES variable and read out the value for jdbcURL. See this blog entry for details.