{"record":{"id":"1ee424199b861610","repo":"testcontainers/testcontainers-java","slug":"the-tidb-docker-image-does-not-currently-support-this","errorCode":null,"errorMessage":"The TiDB docker image does not currently support this","messagePattern":"The TiDB docker image does not currently support this","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/tidb/src/main/java/org/testcontainers/tidb/TiDBContainer.java","lineNumber":124,"sourceCode":"\n    @Override\n    public String getUsername() {\n        return username;\n    }\n\n    @Override\n    public String getPassword() {\n        return password;\n    }\n\n    @Override\n    public String getTestQueryString() {\n        return \"SELECT 1\";\n    }\n\n    @Override\n    public TiDBContainer withDatabaseName(final String databaseName) {\n        throw new UnsupportedOperationException(\"The TiDB docker image does not currently support this\");\n    }\n\n    @Override\n    public TiDBContainer withUsername(final String username) {\n        throw new UnsupportedOperationException(\"The TiDB docker image does not currently support this\");\n    }\n\n    @Override\n    public TiDBContainer withPassword(final String password) {\n        throw new UnsupportedOperationException(\"The TiDB docker image does not currently support this\");\n    }\n}\n","sourceCodeStart":106,"sourceCodeEnd":137,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/tidb/src/main/java/org/testcontainers/tidb/TiDBContainer.java#L106-L137","documentation":"TiDBContainer overrides withDatabaseName purely to reject it: the TiDB docker image's default startup scripts do not support creating a custom initial database, so this unsupported operation is thrown immediately instead of failing later in container startup.","triggerScenarios":"Calling withDatabaseName(\"mydb\") on a TiDBContainer before start().","commonSituations":"Shared JDBC URL builder code that calls withDatabaseName on every JDBCContainer; switching a test from MySQLContainer to TiDBContainer without removing database-name customization.","solutions":["Remove the withDatabaseName call and use the default database name returned by getDatabaseName().","Create your database with a plain JDBC statement after the container starts: execute 'CREATE DATABASE mydb' via the container's DataSource/JDBC URL.","If database-name customization is essential, keep using MySQLContainer (TiDB is wire-compatible)."],"exampleFix":"// before\nnew TiDBContainer(\"pingcap/tidb:v7.5.0\").withDatabaseName(\"appdb\").start();\n// after\nTiDBContainer c = new TiDBContainer(\"pingcap/tidb:v7.5.0\");\nc.start();\ntry (Connection cn = DriverManager.getConnection(c.getJdbcUrl(), c.getUsername(), c.getPassword())) {\n    cn.createStatement().execute(\"CREATE DATABASE appdb\");\n}","handlingStrategy":"validation","validationCode":"if (container instanceof TiDBContainer && wantsCustomDatabase) {\n    throw new IllegalStateException(\"TiDBContainer does not support withDatabaseName; create the database via SQL after start\");\n}","typeGuard":null,"tryCatchPattern":"try { container.withDatabaseName(\"appdb\"); } catch (UnsupportedOperationException e) { /* use default database or create via JDBC post-start */ }","preventionTips":["Do not route TiDB containers through generic JDBC-container builders that set database name.","Create extra databases with CREATE DATABASE after start()."],"tags":["tidb","testcontainers","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}