Custom service connector for DB2 service in pivotal cloud foundry

1.8k Views Asked by At

I have a spring boot app which i am trying to connect to DB2 service.But i am getting No service connection creator exception as pivotal cloud foundry has support for Mongo db and few other db's.Can anyone tell how to write custom service connector in spring boot app for DB2 service ?

1

There are 1 best solutions below

7
On

Create the DB2 service as a user-provided service using the command line:

cf cups db2-service -p "uri,user,password"

You will be prompted for the parameters. Enter user, password, and URI:

jdbc:db2://<host>[:<port>]/<database_name>

Make sure you have Cloud Connectors declared in your pom.xml:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>

Bind the service to your app. Now you can access the database through declarations like:

@Autowired
JdbcTemplate _jdbcTemplate;