Adapter: H2

View as Markdown

The H2 adapter was contributed by community member clang-engineer.

See the harlequin-h2 repository for the most up-to-date documentation.

Installation

Install the adapter into the same environment as Harlequin:

uv tool install harlequin --with harlequin-h2

The adapter requires a Java runtime compatible with your H2 version and an H2 2.x JDBC driver JAR. If the adapter does not discover the JAR automatically, provide its path with --jar or the H2_JAR environment variable.

Usage

Select the adapter with -a h2 and pass an H2 JDBC URL.

Embedded file database

harlequin -a h2 -U sa \
  "jdbc:h2:file:/path/to/database;AUTO_SERVER=TRUE;IFEXISTS=TRUE"

AUTO_SERVER=TRUE allows Harlequin and another JVM process to share the file. IFEXISTS=TRUE prevents a mistyped path from creating a new empty database.

Embedded memory database

harlequin -a h2 "jdbc:h2:mem:demo"

The named database normally exists until its last connection closes. Add ;DB_CLOSE_DELAY=-1 only when it must survive connection closure; H2 then retains it until SHUTDOWN or process exit.

TCP server

harlequin -a h2 -U sa "jdbc:h2:tcp://localhost/~/demo"

Options

  • --jar PATH: Path to the H2 JDBC driver JAR.
  • -U, --user USER: H2 username; defaults to sa.
  • --password PASSWORD: H2 password; defaults to an empty string.

Prefer a protected Harlequin profile or an environment-variable reference for passwords because command-line arguments may be visible to other local processes.