Closed
Description
Docker compose example:
services:
sqlserver:
image: 'mcr.microsoft.com/mssql/server:latest'
environment:
- 'ACCEPT_EULA=yes'
- 'MSSQL_PID=express'
- 'MSSQL_SA_PASSWORD=password'
ports:
- '1433'
labels:
org.springframework.boot.jdbc.parameters: sendStringParametersAsUnicode=false
Gives the following error message while trying to start the application:
SQL State : null
Error Code : 0
Message : The port number 54028?sendStringParametersAsUnicode=false is not valid.
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:326) ~[spring-beans-6.1.8.jar:6.1.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[spring-beans-6.1.8.jar:6.1.8]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:952) ~[spring-context-6.1.8.jar:6.1.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) ~[spring-context-6.1.8.jar:6.1.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-3.3.0.jar:3.3.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352) ~[spring-boot-3.3.0.jar:3.3.0]
This is caused in the org.springframework.boot.docker.compose.service.connection.jdbc.JdbcUrlBuilder::getParameters.
private String getParameters(RunningService service) {
String parameters = (String)service.labels().get("org.springframework.boot.jdbc.parameters");
return StringUtils.hasLength(parameters) ? "?" + parameters : "";
}
It appends a "?" when it should be a ";" for SQL Server.