{"record":{"id":"b0fd4b2d1a080dbe","repo":"YunaiV/yudao-cloud","slug":"cannot-determine-the-oracle-database-version-numbe","errorCode":null,"errorMessage":"Cannot determine the Oracle database version number","messagePattern":"Cannot determine the Oracle database version number","errorType":"exception","errorClass":"UnexpectedLiquibaseException","httpStatus":null,"severity":"error","filePath":"sql/dm/flowable-patch/src/main/java/liquibase/database/core/DmDatabase.java","lineNumber":594,"sourceCode":"\n    /**\n     * Returns the maximum number of bytes (NOT: characters) for an identifier. For Oracle <=12c Release 20, this\n     * is 30 bytes, and starting from 12cR2, up to 128 (except for tablespaces, PDB names and some other rather rare\n     * object types).\n     *\n     * @return the maximum length of an object identifier, in bytes\n     */\n    public int getIdentifierMaximumLength() {\n        try {\n            if (getDatabaseMajorVersion() < ORACLE_12C_MAJOR_VERSION) {\n                return SHORT_IDENTIFIERS_LENGTH;\n            } else if ((getDatabaseMajorVersion() == ORACLE_12C_MAJOR_VERSION) && (getDatabaseMinorVersion() <= 1)) {\n                return SHORT_IDENTIFIERS_LENGTH;\n            } else {\n                return LONG_IDENTIFIERS_LEGNTH;\n            }\n        } catch (DatabaseException ex) {\n            throw new UnexpectedLiquibaseException(\"Cannot determine the Oracle database version number\", ex);\n        }\n\n    }\n}\n","sourceCodeStart":576,"sourceCodeEnd":599,"githubUrl":"https://github.com/YunaiV/yudao-cloud/blob/477be9dd49ab7223a972a6abdff0684d6423dec3/sql/dm/flowable-patch/src/main/java/liquibase/database/core/DmDatabase.java#L576-L599","documentation":"Thrown by a Liquibase patch for the DM (Dameng) database, emulating Oracle behavior in DmDatabase.getIdentifierMaximumLength(). It calls getDatabaseMajorVersion() to decide whether identifiers are limited to 30 bytes (pre-12c Oracle) or 128 bytes (12c+). When the underlying version query fails, the DatabaseException is wrapped in UnexpectedLiquibaseException with this message.","triggerScenarios":"Liquibase runs getIdentifierMaximumLength() (e.g. when comparing/normalizing object names in a changeset) against a DM database and the JDBC connection cannot execute the version query: connection already closed, DM driver incompatibility, insufficient privileges, or an unparseable version string from DatabaseMetaData.getDatabaseProductVersion().","commonSituations":"Running Flowable/Liquibase on DM (Dameng) with a driver version that does not report Oracle-compatible version strings; pooled connection that was invalidated between checkout and use; DM compatibility mode set to a non-Oracle mode so the version query returns unexpected output.","solutions":["Check the chained cause (DatabaseException) for the real failure: closed connection, privilege, or version-parse error.","Verify DM JDBC connectivity from the same process (simple SELECT 1) and that the connection is still open when Liquibase runs.","Use a DM driver / DM compatibility mode (e.g. COMPATIBLE=ORACLE) whose DatabaseMetaData reports a version string Liquibase can parse.","If the DM version is fixed and known, subclass DmDatabase and override getIdentifierMaximumLength() to return the constant directly."],"exampleFix":"// before\nDatabase db = ...; // DmDatabase\nint len = db.getIdentifierMaximumLength(); // may throw\n\n// after\nif (db instanceof DmDatabase) {\n    try {\n        len = db.getIdentifierMaximumLength();\n    } catch (UnexpectedLiquibaseException e) {\n        len = 30; // DM default: short identifiers\n    }\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check connectivity before running Liquibase\ntry (Connection c = dataSource.getConnection();\n     Statement s = c.createStatement();\n     ResultSet rs = s.executeQuery(\"SELECT 1\")) {\n    // connection usable; version metadata likely reachable\n}","typeGuard":null,"tryCatchPattern":"try {\n    int len = database.getIdentifierMaximumLength();\n} catch (UnexpectedLiquibaseException e) {\n    if (e.getMessage().contains(\"Oracle database version\")) {\n        log.warn(\"Falling back to 30-byte identifiers; check DM driver\", e.getCause());\n        len = 30;\n    } else throw e;\n}","preventionTips":["Validate DM connectivity and DatabaseMetaData.getDatabaseProductVersion() parses before invoking Liquibase","Run Liquibase on a freshly validated connection, not a long-idle pooled one","Pin a DM driver version known to report Oracle-compatible metadata"],"tags":["liquibase","database","dameng","oracle","version","identifier"],"backgroundTag":null,"analyzedSha":"477be9dd49ab7223a972a6abdff0684d6423dec3","analyzedAt":"2026-08-14T13:35:31.121Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}