{"record":{"id":"f49e70046371c184","repo":"alibaba/spring-ai-alibaba","slug":"unsupported-database-dialect-dialect-supported","errorCode":null,"errorMessage":"Unsupported database dialect: {dialect}. Supported dialects: H2, MySQL, PostgreSQL, Oracle","messagePattern":"Unsupported database dialect: (.+?)\\. Supported dialects: H2, MySQL, PostgreSQL, Oracle","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java","lineNumber":412,"sourceCode":"     * @param conn          database connection\n     * @param itemId        item id\n     * @param namespaceJson serialized namespace\n     * @param key           key name\n     * @param valueJson     serialized value\n     * @param createdAt     created timestamp\n     * @param updatedAt     updated timestamp\n     * @throws SQLException if SQL execution fails\n     */\n    private void executeUpsert(Connection conn, String itemId, String itemHash, String namespaceJson, String key, String valueJson,\n                               Timestamp createdAt, Timestamp updatedAt) throws SQLException {\n        DatabaseDialect dialect = getDatabaseDialect(conn);\n        switch (dialect) {\n            case H2 -> executeH2Merge(conn, itemId, itemHash, namespaceJson, key, valueJson, createdAt, updatedAt);\n            case MYSQL -> executeMysqlUpsert(conn, itemId, itemHash, namespaceJson, key, valueJson, createdAt, updatedAt);\n            case POSTGRESQL -> executePostgresqlUpsert(conn, itemId, itemHash, namespaceJson, key, valueJson, createdAt,\n                    updatedAt);\n            case ORACLE -> executeOracleUpsert(conn, itemId, itemHash, namespaceJson, key, valueJson, createdAt, updatedAt);\n            case OTHER -> throw new UnsupportedOperationException(\n                    \"Unsupported database dialect: \" + dialect + \". Supported dialects: H2, MySQL, PostgreSQL, Oracle\");\n        }\n    }\n\n    /**\n     * H2 database UPSERT implementation using MERGE INTO syntax.\n     *\n     * @param conn          database connection\n     * @param itemId        unique primary key\n     * @param namespaceJson serialized namespace\n     * @param key           business key\n     * @param valueJson     serialized value\n     * @param createdAt     created timestamp\n     * @param updatedAt     updated timestamp\n     * @throws SQLException if SQL execution fails\n     */\n    private void executeH2Merge(Connection conn, String itemId, String itemHash, String namespaceJson, String key, String valueJson,\n                                Timestamp createdAt, Timestamp updatedAt) throws SQLException {","sourceCodeStart":394,"sourceCodeEnd":430,"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#L394-L430","documentation":"executeUpsert switches on the detected/declared database dialect; when the dialect resolves to OTHER (not one of H2, MySQL, PostgreSQL, Oracle) it throws UnsupportedOperationException with this message. The store only has vendor-specific UPSERT implementations for those four databases.","triggerScenarios":"Configuring DatabaseStore with a dbType/jdbcUrl whose dialect cannot be mapped (e.g. MariaDB reported as OTHER, SQL Server, SQLite, or a misspelled dbType string), then calling putItem.","commonSituations":"Using a database that speaks a MySQL-like protocol but identifies differently (MariaDB); unsupported DB chosen because 'it's just SQL'; typo in dbType such as 'postgres' vs expected spelling that fails dialect detection.","solutions":["Use one of the supported dialects: H2, MySQL, PostgreSQL, or Oracle","Check the exact dbType string/driver the store detects from the JDBC URL and correct it (e.g. 'postgresql')","If your DB is MySQL-compatible, force the MySQL dialect in configuration instead of relying on auto-detection"],"exampleFix":"// before\nDatabaseStore.builder().dbType(\"mariadb\").build();\n// after\nDatabaseStore.builder().dbType(\"mysql\").build(); // MySQL-compatible upsert syntax","handlingStrategy":"validation","validationCode":"java.util.Set<String> supported = java.util.Set.of(\"h2\",\"mysql\",\"postgresql\",\"oracle\");\nif (!supported.contains(dbType.toLowerCase())) throw new IllegalArgumentException(\"Unsupported dbType: \" + dbType);","typeGuard":"boolean isSupportedDialect(String dbType) { return dbType != null && java.util.Set.of(\"h2\",\"mysql\",\"postgresql\",\"oracle\").contains(dbType.toLowerCase()); }","tryCatchPattern":"try { store.putItem(item); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Unsupported database dialect\")) { log.error(\"Switch to H2/MySQL/PostgreSQL/Oracle or force a compatible dialect\"); } throw e; }","preventionTips":["Verify dialect auto-detection against your actual DB vendor (MariaDB is not auto-mapped)","Use an allow-list enum for dbType in configuration","Test store writes against the target database in CI before deploying"],"tags":["database","unsupported-operation","dialect"],"backgroundTag":"unsupported-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}