YunaiV/ruoyi-vue-pro · error · UnexpectedLiquibaseException

Cannot determine the Oracle database version number

Error message

Cannot determine the Oracle database version number

What it means

Thrown by DmDatabase (a Liquibase Database implementation for Dameng DB, which mirrors Oracle) when getIdentifierMaximumLength() cannot read the database major/minor version. The method calls getDatabaseMajorVersion()/getDatabaseMinorVersion(), which raise DatabaseException if the JDBC driver does not report a parseable version string. The catch wraps it as an UnexpectedLiquibaseException, halting the Liquibase changelog parse/identifier-length decision.

Source

Thrown at sql/dm/flowable-patch/src/main/java/liquibase/database/core/DmDatabase.java:594

    /**
     * Returns the maximum number of bytes (NOT: characters) for an identifier. For Oracle <=12c Release 20, this
     * is 30 bytes, and starting from 12cR2, up to 128 (except for tablespaces, PDB names and some other rather rare
     * object types).
     *
     * @return the maximum length of an object identifier, in bytes
     */
    public int getIdentifierMaximumLength() {
        try {
            if (getDatabaseMajorVersion() < ORACLE_12C_MAJOR_VERSION) {
                return SHORT_IDENTIFIERS_LENGTH;
            } else if ((getDatabaseMajorVersion() == ORACLE_12C_MAJOR_VERSION) && (getDatabaseMinorVersion() <= 1)) {
                return SHORT_IDENTIFIERS_LENGTH;
            } else {
                return LONG_IDENTIFIERS_LEGNTH;
            }
        } catch (DatabaseException ex) {
            throw new UnexpectedLiquibaseException("Cannot determine the Oracle database version number", ex);
        }

    }
}

View on GitHub (pinned to 0418084e22)

Solutions

  1. Upgrade the Dameng JDBC driver (DmJdbcDriver) to a version that correctly reports database major/minor version metadata.
  2. Verify the connection is healthy and the instance is fully started before Liquibase runs (e.g. a readiness check on the datasource).
  3. Check the caused-by DatabaseException in the stack trace to see which metadata call (getDatabaseMajorVersion vs getDatabaseMinorVersion) failed and what string the driver returned.
  4. If the version truly cannot be detected, override DmDatabase.getDatabaseMajorVersion()/getDatabaseMinorVersion() in the patch to return a known constant for your target DM version.

Example fix

// before: rely on driver metadata which may be missing
return getDatabaseMajorVersion();
// after: fall back to a configured/default DM major version
int major;
try {
    major = getDatabaseMajorVersion();
} catch (DatabaseException e) {
    major = DEFAULT_DM_MAJOR_VERSION;
}
return major;
Defensive patterns

Strategy: try-catch

Validate before calling

// before engine init, probe metadata once
try (Connection c = dataSource.getConnection()) {
    int major = c.getMetaData().getDatabaseMajorVersion();
    if (major <= 0) throw new IllegalStateException("Driver returned invalid DB major version");
} catch (SQLException e) {
    throw new IllegalStateException("DB not ready for metadata queries", e);
}

Type guard

null

Try / catch

try {
    return database.getIdentifierMaximumLength();
} catch (UnexpectedLiquibaseException e) {
    log.warn("DM version undetectable, defaulting identifier length", e);
    return LONG_IDENTIFIERS_LEGNTH;
}

Prevention

When it happens

Trigger: Running a Liquibase update against a Dameng/Oracle-compatible DB whose JDBC driver returns null or a malformed version from DatabaseMetaData.getDatabaseMajorVersion(); connecting before the DB is fully started so metadata calls fail; using an older DmJdbcDriver that does not implement version metadata.

Common situations: Upgrading the Dameng JDBC driver to a build that changed the version metadata format; pointing Flowable/Liquibase at a standby or read-only replica that refuses metadata queries; CI containers where the DB is queried before init scripts finish.

Related errors


AI-assisted analysis of YunaiV/ruoyi-vue-pro@0418084e22 (2026-08-14). Data as JSON: /api/errors/68ca8ec2a736506b. Report an issue: GitHub.