Skip to content

Explain missing JDBC driver for R2DBC users of MySQL, MariaDB and MSSQL - #12118

Open
caiocv18 wants to merge 1 commit into
testcontainers:mainfrom
caiocv18:r2dbc-jdbc-driver-hint
Open

caiocv18 wants to merge 1 commit into
testcontainers:mainfrom
caiocv18:r2dbc-jdbc-driver-hint

Conversation

@caiocv18

@caiocv18 caiocv18 commented Oct 18, 2026 •

Copy link
Copy Markdown

Problem

MySQLContainer, MariaDBContainer and MSSQLServerContainer do not override waitUntilContainerStarted(), so they use the default JdbcDatabaseContainer startup check, which opens a JDBC connection and runs the test query. A project that only uses R2DBC (testcontainers-r2dbc + r2dbc-mssql, for example) therefore still needs the JDBC driver on the test classpath. Without it, the container fails with:

JdbcDatabaseContainer$NoDriverFoundException: Could not get Driver

The driver class name only shows up in the ClassNotFoundException cause, and neither r2dbc.md nor the module pages mention that R2DBC users need the JDBC driver. modules/mssqlserver/build.gradle already notes it internally (// MSSQL's wait strategy requires the JDBC driver), but it does not reach users. Related questions: #4610 / #4611, #9465 (ClickHouse, solved there by changing the wait strategy in #9466).

PostgreSQL, Oracle Free and ClickHouse override the startup check, so they are not affected.

Changes

  • JdbcDatabaseContainer.getJdbcDriverInstance(): the NoDriverFoundException message now names the driver class and explains why it is required, also for R2DBC-only applications. The message still starts with Could not get Driver.
  • MissingJdbcDriverTest.shouldNameTheMissingDriverClass: asserts the new message; it calls getJdbcDriverInstance() directly, so it does not need Docker.
  • Docs: a warning in r2dbc.md and one sentence in the existing driver hint of mysql.md, mariadb.md and mssqlserver.md.

No behavior change; the wait strategy is untouched (changing it for MSSQL looked riskier, and #12080 is moving PostgreSQL in the opposite direction).

Verification

  • ./gradlew :testcontainers-jdbc:test --tests org.testcontainers.jdbc.MissingJdbcDriverTest.shouldNameTheMissingDriverClass: green
  • ./gradlew :testcontainers-jdbc:spotlessCheck :testcontainers-jdbc:compileTestJava :testcontainers-r2dbc:compileTestJava: green
  • I could not run the Docker-based tests locally (no Docker daemon on this machine); the existing shouldFailFastIfNoDriverFound only asserts the root cause type, which is unchanged.

Summary by CodeRabbit

  • Documentation
    • Clarified that MySQL, MariaDB, and MS SQL Server require a JDBC driver for container startup checks, even when applications use only R2DBC.
    • Documented the startup failure that can occur when the driver is missing.
  • Bug Fixes
    • Missing-driver errors now identify the required driver and explain why it is needed; the original cause is preserved.

MySQLContainer, MariaDBContainer and MSSQLServerContainer use the default
JdbcDatabaseContainer startup check, which connects over JDBC. Projects
that only use R2DBC therefore still need the JDBC driver on the test
classpath, and without it the container fails with a bare
"Could not get Driver".

- Name the driver class in the NoDriverFoundException message and say why
  it is needed, also when the application only uses R2DBC
- Document the requirement in the R2DBC page and in the MySQL, MariaDB
  and MS SQL Server module pages
- Add a unit test for the message that does not need Docker
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d55249d9-779b-4ae4-8c6b-92f1e487481e
📥 Commits

Reviewing files that changed from the base of the PR and between a8be77b and e56cdd7.

📒 Files selected for processing: 6
  • docs/modules/databases/mariadb.md
  • docs/modules/databases/mssqlserver.md
  • docs/modules/databases/mysql.md
  • docs/modules/databases/r2dbc.md
  • modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java
  • modules/jdbc/src/test/java/org/testcontainers/jdbc/MissingJdbcDriverTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The missing-driver exception now names the required JDBC driver and explains its use in startup checks. Documentation for R2DBC and MySQL, MariaDB, and MS SQL Server states that the JDBC driver is required for those checks. A test verifies the exception message and cause.

Changes: JDBC driver requirement guidance

Layer / File(s) Summary
Driver requirement message and guidance
modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java, modules/jdbc/src/test/java/org/testcontainers/jdbc/MissingJdbcDriverTest.java, docs/modules/databases/r2dbc.md, docs/modules/databases/mariadb.md, docs/modules/databases/mssqlserver.md, docs/modules/databases/mysql.md
The missing-driver exception message identifies the driver class and states that startup checks use JDBC, including for R2DBC-only applications. The test checks the message and cause. The database documentation states the driver requirement.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: rnorth

Merge Risk: ⚪ Minimal · up to e56cd

The clearer message and documentation should help R2DBC-only users identify the missing JDBC dependency. No concrete merge-blocking risk is established, so the change is mergeable under normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (4 skipped: 4… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: documenting the missing JDBC driver requirement for R2DBC users of MySQL, MariaDB, and MSSQL.
Description check Passed The description is complete. It explains the problem, affected modules, error behavior, implementation changes, documentation updates, scope, related issues, and verification results, including the Do…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete. It explains the problem, affected modules, error behavior, implementation changes, documentation updates, scope, related issues, and verification results, including the Docker test limitation.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant