testcontainers/testcontainers-java · error · UnsupportedOperationException

Database name not supported

Error message

Database name {} not supported

What it means

Testcontainers' JDBC proxy driver (jdbc:tc:// URLs) throws this UnsupportedOperationException when no registered JdbcDatabaseContainerProvider supports the database type given in the URL (the part after jdbc:tc:). It means the JDBC URL names a database for which no container provider module is on the classpath or the type string is misspelled.

Solutions

  1. Fix the database type in the jdbc:tc URL (check spelling, e.g. jdbc:tc:postgresql://... not jdbc:tc:postgres://...)
  2. Add the corresponding testcontainers database module dependency, e.g. org.testcontainers:postgresql
  3. Verify the provider is registered via ServiceLoader (dependency actually resolved in the test classpath, not just provided scope)
  4. If a real driver URL was intended, remove the jdbc:tc: prefix and use the vendor driver directly

Example fix

// before
String url = "jdbc:tc:postgres:16:///mydb";
// after
String url = "jdbc:tc:postgresql:16:///mydb"; // plus dependency org.testcontainers:postgresql
Defensive patterns

Strategy: validation

Validate before calling

String dbType = url.startsWith("jdbc:tc:") ? url.substring("jdbc:tc:".length()).split(":")[0] : null;
Set<String> known = Set.of("postgresql","mysql","mariadb","mssqlserver","oracle","db2","clickhouse","neo4j");
if (dbType == null || !known.contains(dbType)) throw new IllegalArgumentException("Unsupported jdbc:tc database type: " + dbType);

Prevention

When it happens

Trigger: Calling DriverManager.getConnection with a jdbc:tc://<dbtype>://... URL where <dbtype> does not match any provider's supports() check — e.g. a typo like 'postgresl', or using a type whose container module (e.g. testcontainers postgresql/mssql/oracle modules) is not a Maven dependency.

Common situations: Forgot to add the testcontainers database-module dependency for that DB; typo'd the database type in the JDBC URL; upgraded testcontainers and the module split; copying a URL from a different project.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/c1cca4ca412bd0ce. Report an issue: GitHub.

Appendix: source

Thrown at modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java:115

                LOGGER.debug("Container not found in cache, creating new instance");

                Map<String, String> parameters = connectionUrl.getContainerParameters();

                /*
                  Find a matching container type using ServiceLoader.
                 */
                ServiceLoader<JdbcDatabaseContainerProvider> databaseContainers = ServiceLoader.load(
                    JdbcDatabaseContainerProvider.class
                );
                for (JdbcDatabaseContainerProvider candidateContainerType : databaseContainers) {
                    if (candidateContainerType.supports(connectionUrl.getDatabaseType())) {
                        container = candidateContainerType.newInstance(connectionUrl);
                        container.withTmpFs(connectionUrl.getTmpfsOptions());
                        delegate = container.getJdbcDriverInstance();
                    }
                }
                if (container == null) {
                    throw new UnsupportedOperationException(
                        "Database name " + connectionUrl.getDatabaseType() + " not supported"
                    );
                }

                /*
                  Cache the container before starting to prevent race conditions when a connection
                  pool is started up
                 */
                jdbcUrlContainerCache.put(url, container);

                /*
                  Pass possible container-specific parameters
                 */
                container.setParameters(parameters);

                /*
                  Start the container
                 */

View on GitHub (pinned to 8e549514e3)