Enum Class DatabaseType

java.lang.Object
java.lang.Enum<DatabaseType>
org.apache.polaris.persistence.relational.jdbc.DatabaseType
All Implemented Interfaces:
Serializable, Comparable<DatabaseType>, Constable

public enum DatabaseType extends Enum<DatabaseType>
Database types supported by Polaris relational JDBC persistence.

CockroachDB uses the PostgreSQL wire protocol but has its own schema resources in the "cockroachdb" directory. While CockroachDB is PostgreSQL-compatible, having separate schemas allows for CockroachDB-specific optimizations and avoids experimental ALTER operations that CockroachDB doesn't fully support.

  • Enum Constant Details

  • Method Details

    • values

      public static DatabaseType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DatabaseType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDisplayName

      public String getDisplayName()
    • getLatestSchemaVersion

      public int getLatestSchemaVersion()
      Returns the latest schema version available for this database type. This is used as the default schema version for new installations.
    • fromDisplayName

      public static DatabaseType fromDisplayName(String displayName)
    • inferFromConnection

      public static DatabaseType inferFromConnection(Connection connection, DatabaseType configuredType)
      Determines the database type from JDBC connection metadata and validates against configured type.

      Logic:

      • If configuredType is provided: uses it as the authoritative type and validates it matches what the connection reports. Throws an exception if there's a mismatch.
      • If configuredType is null: infers the type from connection metadata.
      Parameters:
      connection - JDBC connection to inspect
      configuredType - Explicitly configured database type (may be null)
      Returns:
      The database type (configured if provided, otherwise inferred)
      Throws:
      IllegalStateException - if configured type doesn't match connection metadata
    • openInitScriptResource

      public InputStream openInitScriptResource(int schemaVersion)
      Open an InputStream that contains data from an init script. This stream should be closed by the caller.