1

I am using the spring jdbc template for spring mvc project. I want to create the connection pool in cloud foundry. Currently I am using Springmvc4 using Jdbc template with tomcat 9. How to connect the cloud foundry with connection pooling using hikari and tomcat?

I have tried in tomcat servlet.xml and context.xml configurations for connection pooling. In cloud foundry is not reading that configuration. Connection pooling it should worked in spring mvc4 xml based approach.

Vega
  • 27,856
  • 27
  • 95
  • 103
JavaAbdul
  • 13
  • 3

1 Answers1

0

Replace your bean definition with the id ds with one that defines the DataSource you want to use. For Hakari see this SO post -> https://stackoverflow.com/a/24500712/1585136.

You shouldn't need to do anything with Tomcat, so remove anything you were doing and just let CF & the Java buildpack configure that for you.

You also don't need to do anything CF specific with your datasource. You can plug in the configuration values it needs using a property place holder and resolve them from a properties file included with your app.


If, and only if you want since it's not a requirement, you can look at service binding to make managing configuration data easier. When doing this, you would create a service instance in CF, bind that to your app and then CF would provide your app with the configuration for that service. When this happens, you don't need to bundle the service configuration with your app, it dynamically adjust to the service that is bound to your app.

To get started with service binding, read the docs here -> https://docs.cloudfoundry.org/buildpacks/java/configuring-service-connections/spring-service-bindings.html

There are a variety of ways you can do service binding and the link above covers them all with examples. I would recommend using a combination of the "cloud" profile & cloud property placeholders, or using the "Manual Configuration" section. Skip the auto reconfiguraton. It sounds tempting but beyond some demo flash, it's more trouble than it's worth.

Hope that helps!

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28