{"record":{"id":"30bc4acb56928e80","repo":"alibaba/spring-ai-alibaba","slug":"unsupported-dbtype-dbtype-supported-values-my","errorCode":null,"errorMessage":"Unsupported dbType: {dbType}. Supported values: mysql, postgresql, oracle, h2","messagePattern":"Unsupported dbType: (.+?)\\. Supported values: mysql, postgresql, oracle, h2","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java","lineNumber":192,"sourceCode":"     * Build a JDBC URL from simple connection parameters.\n     *\n     * @param dbType   database type\n     * @param host     database host\n     * @param port     database port\n     * @param database database name (or service name for Oracle)\n     * @return normalized JDBC URL\n     */\n    public static String buildJdbcUrl(String dbType, String host, int port, String database) {\n        validateConnectionInfo(dbType, host, port, database);\n        String normalized = dbType.trim().toLowerCase(Locale.ROOT);\n        return switch (normalized) {\n            // MySQL supports optional auto database creation via URL parameters.\n            case \"mysql\" -> \"jdbc:mysql://\" + host + \":\" + port + \"/\" + database\n                    + \"?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC\";\n            case \"postgresql\", \"postgres\", \"pgsql\" -> \"jdbc:postgresql://\" + host + \":\" + port + \"/\" + database;\n            case \"oracle\" -> \"jdbc:oracle:thin:@\" + host + \":\" + port + \":\" + database;\n            case \"h2\" -> \"jdbc:h2:mem:\" + database + \";DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE\";\n            default -> throw new IllegalArgumentException(\n                    \"Unsupported dbType: \" + dbType + \". Supported values: mysql, postgresql, oracle, h2\");\n        };\n    }\n\n    /**\n     * Validate connection parameters for JDBC URL construction.\n     *\n     * @param dbType   database type\n     * @param host     database host\n     * @param port     database port\n     * @param database database name\n     */\n    private static void validateConnectionInfo(String dbType, String host, int port, String database) {\n        if (dbType == null || dbType.isBlank()) {\n            throw new IllegalArgumentException(\"dbType cannot be null or blank\");\n        }\n        if (host == null || host.isBlank()) {\n            throw new IllegalArgumentException(\"host cannot be null or blank\");","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java#L174-L210","documentation":"DatabaseStore.buildJdbcUrl switches on the configured dbType and throws IllegalArgumentException for any value outside mysql, postgresql/postgres/pgsql, oracle, and h2. The dbType comes from store configuration; a typo or unsupported database means no JDBC URL can be constructed.","triggerScenarios":"Configuring DatabaseStore with dbType values like \"MySQL\" (uppercase), \"mariadb\", \"sqlserver\", \"db2\", or any misspelling; the switch's default branch fires when jdbcUrl is built.","commonSituations":"Case-sensitivity mistakes (\"PostgreSQL\" instead of \"postgresql\"); attempting to use an unsupported database (SQL Server, SQLite, MariaDB); config from environment variables with wrong values; docs referencing dialect names not in the supported list.","solutions":["Set dbType to exactly one of: mysql, postgresql (or postgres/pgsql), oracle, h2 — lowercase.","Normalize/trim the dbType config value before constructing DatabaseStore.","For an unsupported database, switch to a supported one (e.g. H2 for testing, PostgreSQL for production) or provide a custom Store implementation.","Catch IllegalArgumentException at startup and fail fast with the list of supported values."],"exampleFix":"// before\nDatabaseStore store = DatabaseStore.builder()\n        .dbType(config.get(\"db_type\")) // \"PostgreSQL\"\n        ...\n// after\nString dbType = config.get(\"db_type\").trim().toLowerCase();\nif (!Set.of(\"mysql\", \"postgresql\", \"postgres\", \"pgsql\", \"oracle\", \"h2\").contains(dbType)) {\n    throw new IllegalArgumentException(\"Unsupported dbType: \" + dbType);\n}\nDatabaseStore store = DatabaseStore.builder().dbType(dbType)...","handlingStrategy":"validation","validationCode":"Set<String> SUPPORTED = Set.of(\"mysql\", \"postgresql\", \"postgres\", \"pgsql\", \"oracle\", \"h2\");\nString dbType = cfg.dbType() == null ? null : cfg.dbType().trim().toLowerCase();\nif (dbType == null || !SUPPORTED.contains(dbType)) {\n    throw new IllegalArgumentException(\"dbType must be one of \" + SUPPORTED);\n}\nDatabaseStore store = DatabaseStore.builder().dbType(dbType).build();","typeGuard":"boolean isSupportedDbType(String t) {\n    return t != null && Set.of(\"mysql\", \"postgresql\", \"postgres\", \"pgsql\", \"oracle\", \"h2\").contains(t.trim().toLowerCase());\n}","tryCatchPattern":"try {\n    DatabaseStore store = DatabaseStore.builder().dbType(cfg.dbType()).build();\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Bad dbType in config: \" + e.getMessage(), e);\n}","preventionTips":["Keep dbType values lowercase in configuration; normalize at load time.","Fail fast at startup by building the store eagerly, not lazily on first use.","Restrict config values with an allowlist instead of free text.","Check the supported dialect list in DatabaseStore docs before adding a new database."],"tags":["java","configuration","jdbc","database"],"backgroundTag":"invalid-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}