Spring User
Spring User

Reputation: 53

Custom service connector for DB2 service in pivotal cloud foundry

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 ?

Upvotes: 0

Views: 1812

Answers (1)

Corby Page
Corby Page

Reputation: 1405

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;

Upvotes: 0

Related Questions