Open
Description
openedon Jun 9, 2019
I tried to use test containers with hikari data-source-properties in Spring Boot like this:
spring:
datasource:
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver
url: jdbc:tc:mysql:5.7.22://testcontainers/hi_perf_java_pers #?rewriteBatchedStatements=true&profileSQL=true&logger=com.mysql.cj.log.Slf4JLogger
hikari:
data-source-properties:
rewriteBatchedStatements: true
profileSQL: true
logger: com.mysql.cj.log.Slf4JLogger
But datasource properties are ignored by connect method inside ContainerDatabaseDriver
(info
parameter in method connect
).
Workaround so far is to include properties directly into connection string (commented part in url #?rewriteBatched...
).
MySQL driver is doing it in this way:
/**
* Builds a connection URL cache map key based on the connection string itself plus the string representation of the given connection properties.
*
* @param connString
* the connection string
* @param info
* the connection arguments map
* @return a connection string cache map key
*/
private static String buildConnectionStringCacheKey(String connString, Properties info) {
StringBuilder sbKey = new StringBuilder(connString);
sbKey.append("\u00A7"); // Section sign.
sbKey.append(
info == null ? null : info.stringPropertyNames().stream().map(k -> k + "=" + info.getProperty(k)).collect(Collectors.joining(", ", "{", "}")));
return sbKey.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment