Skip to content

[Enhancement]: ContainerDatabaseDriver ignores additional JDBC properties #5622

Closed

Description

@zarebski-m

Module

MySQL

Proposal

Happens for MySQL, but the issue is more general. JDBC allows specifying additional properties as a key/value pair when connecting to the DB:

https://docs.oracle.com/javase/7/docs/api/java/sql/Driver.html#connect(java.lang.String,%20java.util.Properties)

Those should be used as if they were appended to JDBC URL, e.g.:

var info = new Properties();
info.put("allowMultiQueries", "true");
driver.connect("jdbc:tc:mysql:5.7:///?TC_TMPFS=/var/lib/mysql:rw", info);

This should have the same effect as JDBC URL jdbc:tc:mysql:5.7:///?TC_TMPFS=/var/lib/mysql:rw&allowMultiQueries=true.

For example in Spring Boot, one can define JDBC properties through application properties, without changing the original JDBC URL:

spring:
  datasource:
    url: jdbc:mysql://localhost/test
    hikari:
      data-source-properties:
        characterEncoding: UTF-8
        useUnicode: true

This configuration does not work in Testcontainers because data-source-properties are passed as the second argument of Driver#connect method, and ContainerDatabaseDriver is simply ignoring them.

Activity

  1. s-jepsen commented on Sep 2, 2022

    @s-jepsen

    Any progress on this?

  2. aidando73 commented on Sep 8, 2022

    @aidando73
    Contributor
    var info = new Properties();
    info.put("allowMultiQueries", "true");
    driver.connect("jdbc:tc:mysql:5.7:///?TC_TMPFS=/var/lib/mysql:rw", info);
    

    I've been able to reproduce this on my end. It looks like ContainerDatabaseDriver#connect ignores the info argument completely. Thanks for the issue @zarebski-m. Let me look into this.

  3. added this to the next milestone on Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions