0

I had configured mssql as a user provided service in pcf. had created a java application with springboot and flywaydb for migration. When i try to deploy my java application into pcf it gives me the error "Caused by: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!". Had bind my app to the mssql service and restarted the application in pcf, but still the same error.

application.properties

spring.datasource.url=${vcap.services.db.credentials.jdbcUrl}
spring.datasource.username=${vcap.services.db.credentials.username}
spring.datasource.password=${vcap.services.db.credentials.password}
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect

mssql configuration in pcf

uri : sqlserver://xxx:yyy@zzz:1433/db

username : xxx

password : yyy

expected : server should start without any issues and the tables should be created as mentioned in the migration sql file

actual : error "Caused by: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!".

  • 2
    Jdbc Connection url format should be like `jdbc:sqlserver://zzz:1433` and `spring.datasource.username` & `spring.datasource.password` values will be used for connection authentication. Could you try changing the `spring.datasource.url` in the format I mentioned? – miiiii Aug 23 '19 at 11:11
  • 1
    It's probably what @miiiii mentioned, but also check that `db` is the name of the service instance bound to the app. If the service instance name does not match exactly what's in your config, the property placeholder won't be able to find the credential info. Also, you should consider using java-cfenv instead, see -> https://stackoverflow.com/questions/57581982/unable-to-retrieve-credentials-from-user-provided-in-vcap-services-in-spring-boo/57615761#57615761 – Daniel Mikusa Aug 23 '19 at 17:37

0 Answers0