Interface JdbcDialect

All Known Implementing Classes:
H2Dialect, MySqlDialect, PostgresDialect

public sealed interface JdbcDialect permits MySqlDialect, PostgresDialect, H2Dialect
Vendor abstraction over the small set of column-type / SQL fragments that differ between MySQL, PostgreSQL and H2. The flow engine itself uses vendor-neutral parameterised SQL throughout (see SqlBuilder); dialects only contribute schema-DDL fragments. 数据库方言抽象:仅在 schema DDL 层面区分 MySQL / PostgreSQL / H2 列类型差异。 流程引擎运行时 SQL 由 SqlBuilder 产出,统一参数化,与方言无关。

The sealed hierarchy enumerates the three officially supported vendors. detect(String) inspects a JDBC URL prefix to pick the right impl; any other URL throws IllegalArgumentException.

密封继承层级穷尽三种官方支持的数据库。detect(String) 根据 JDBC URL 前缀挑选实现;不识别的 URL 直接抛 IllegalArgumentException。

Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Method Summary

    Modifier and Type
    Method
    Description
    Column type for boolean columns (e.g.
    detect(String jdbcUrl)
    Detects the appropriate dialect from a JDBC URL.
    Column type for variables_json / dsl_json / extra_json.
    static String
    Masks a JDBC URL so it can be safely embedded in exception messages or logs.
    Short identifier used to pick the matching V1__init_*.sql script (one of "mysql" / "postgres" / "h2").
    Column type for TIMESTAMP columns (with microsecond precision, including time-zone where the dialect supports it).
  • Method Details

    • jsonType

      String jsonType()
      Column type for variables_json / dsl_json / extra_json. variables_json / dsl_json / extra_json 列类型。
      Returns:
      vendor-specific JSON column type — 方言相关 JSON 类型
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • timestampType

      String timestampType()
      Column type for TIMESTAMP columns (with microsecond precision, including time-zone where the dialect supports it). TIMESTAMP 列类型(微秒精度,方言支持时含时区)。
      Returns:
      vendor-specific timestamp column type — 方言相关 TIMESTAMP 类型
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • booleanType

      String booleanType()
      Column type for boolean columns (e.g. flow_comment_template.enabled). boolean 列类型(如 flow_comment_template.enabled)。
      Returns:
      vendor-specific boolean column type — 方言相关 boolean 类型
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • shortName

      String shortName()
      Short identifier used to pick the matching V1__init_*.sql script (one of "mysql" / "postgres" / "h2"). 用于挑选 V1__init_*.sql 脚本的短标识("mysql" / "postgres" / "h2")。
      Returns:
      short identifier — 短标识
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • detect

      static JdbcDialect detect(String jdbcUrl)
      Detects the appropriate dialect from a JDBC URL. 根据 JDBC URL 推断对应方言。

      Recognised prefixes: jdbc:mysql:, jdbc:mariadb:, jdbc:postgresql:, jdbc:h2:. Anything else triggers IllegalArgumentException.

      识别前缀:jdbc:mysql:、jdbc:mariadb:、 jdbc:postgresql:、jdbc:h2:。其它前缀抛 IllegalArgumentException。

      Parameters:
      jdbcUrl - JDBC connection URL — JDBC 连接串
      Returns:
      the matching dialect — 对应方言
      Throws:
      IllegalArgumentException - when the URL prefix is not recognised — URL 前缀不识别
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • maskJdbcUrl

      static String maskJdbcUrl(String jdbcUrl)
      Masks a JDBC URL so it can be safely embedded in exception messages or logs. Returns only the jdbc:<scheme>: prefix; everything after the second colon (host, port, database, query string, and any embedded user:password@ credentials) is replaced with ***. 脱敏 JDBC URL,仅保留 jdbc:<scheme>: 前缀;host/port/database/ 查询串以及形如 user:password@ 的嵌入凭证统一替换为 ***。
      Parameters:
      jdbcUrl - raw JDBC URL (must not be null) — 原始 JDBC URL
      Returns:
      masked URL safe for logging — 适合写日志的脱敏 URL
      Since:
      JDK 25, opencode-base-flow V1.0.5