Testcontainers-java: Unexpected behavior for database containers launched via JDBC URL scheme

Created on 9 Apr 2020  路  7Comments  路  Source: testcontainers/testcontainers-java

Version: 1.13.0
Spring Boot: yes
Container: mariadb:10.4

According to Database containers launched via JDBC URL scheme's note:
We will use /// (host-less URIs) from now on to emphasis the unimportance of the host:port pair.
From Testcontainers' perspective, jdbc:mysql:5.7.22://localhost:3306/databasename and jdbc:mysql:5.7.22:///databasename is the same URI.

This URL jdbc:tc:mariadb:10.4:///users?TC_INITSCRIPT=sql/init.sql should behave as jdbc:tc:mariadb:10.4://localhost:33306/users?TC_INITSCRIPT=sql/init.sql

The result for the first is URL is:
Waiting for database connection to become available at jdbc:mariadb://localhost:32795/test using query 'SELECT 1'

This results in failed TC_INITSCRIPT due to permissions.

For the second is:
Waiting for database connection to become available at jdbc:mariadb://localhost:32797/users using query 'SELECT 1'

This might be missing from #566 and #617.

stale

All 7 comments

Hi! Same here with postgresql in Testcontainers 1.3.0.

In org.testcontainers.containers.JdbcDatabaseContainer#createConnection the url is assigned to the value:

jdbc:postgresql://localhost:33048/test?loggerLevel=OFF?password=somepwd&fsync=off&initScript=&volumePath=/media/data/Docker/src/javister/javister-docker-postgresql/tests/simple/target/test-classes/../simpleWithVolumeTest-9_5&user=system

Note the ?loggerLevel=OFF? substring, that lead to the error. It's because the getJdbcUrl method is returning string:

jdbc:postgresql://localhost:33048/test?loggerLevel=OFF

in one hand, and the ConnectionUrl.getQueryString method starts constructing the query from the ? symbol again.

One more thing: I have update the PostgreSQL JDBC driver from version 42.0.0 to 42.2.12.

@vektory79 your issue seems to be unrelated and fixed in #2049

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

Seems this issue is still valid, it shouldn't be closed.

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

Issue still exists with 1.15.1.

Was this page helpful?
0 / 5 - 0 ratings