Overview

H2 is a lightweight, fast relational database written in Java with key characteristics:

  • Embedded and server modes: Run as an embedded database or standalone server
  • Small footprint: Compact JAR file (~2.5 MB) with minimal dependencies
  • Fast performance: In-memory and disk-based storage with excellent speed
  • SQL compatibility: Supports a large subset of SQL with PostgreSQL and MySQL compatibility modes
  • Browser-based console: Built-in web console for database administration

H2 is ideal for development, testing, embedded applications, and scenarios requiring a lightweight database with minimal setup.

Connecting

To connect to H2 in DBCode, you’ll need:

  1. Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
  2. Add a New Connection: Click on the “Add Connection” icon.
  3. Complete connection form: Select H2 as the database type and enter:
    • Connection type (Embedded, In-Memory, TCP Server, or SSL Server)
    • Database path or name
    • Username and password (default: sa / empty)
  4. Connect: Click save to connect to your H2 database.
  5. Start Managing Your Data: Explore schemas, tables, and run queries.

For detailed instructions on connecting to databases, refer to the Connect article.

H2 Features in DBCode

DBCode enhances your H2 development experience with:

  • SQL query editor: Write and execute SQL queries with syntax highlighting
  • Schema browsing: Navigate through schemas, tables, views, and other objects
  • Data editing: View and modify table data directly
  • DDL generation: Generate CREATE statements for database objects
  • Multiple connection types: Support for embedded, in-memory, and server modes

By using H2 with DBCode, you can efficiently develop and test database applications directly within Visual Studio Code.

For more information about H2, check out H2 Database Engine.