Quickstart - H2 Database Engine

Quickstart Embedding H2 in an Application The H2 Console Application

Embedding H2 in an Application

This database can be used in embedded mode, or in server mode. To use it in embedded mode, you need to:

  • Add the h2*.jar to the classpath (H2 does not have any dependencies)
  • Use the JDBC driver class: org.h2.Driver
  • The database URL jdbc:h2:~/test opens the database test in your user home directory
  • A new database is automatically created

The H2 Console Application

The Console lets you access a SQL database using a browser interface. Web Browser - H2 Console Server - H2 Database If you don't have Windows XP, or if something does not work as expected, please see the detailed description in the Tutorial.

Step-by-Step

Installation

Install the software using the Windows Installer (if you did not yet do that).

Start the Console

Click [Start], [All Programs], [H2], and [H2 Console (Command Line)]: Screenshot: start H2 Console A new console window appears: Screenshot: H2 running Also, a new browser page should open with the URL http://localhost:8082. You may get a security warning from the firewall. If you don't want other computers in the network to access the database on your machine, you can let the firewall block these connections. Only local connections are required at this time.

Login

Select [Generic H2] and click [Connect]: Screenshot: login You are now logged in.

Sample

Click on the [Sample SQL Script]: Screenshot: click on the sample SQL script The SQL commands appear in the command area.

Execute

Click [Run] Screenshot: click Run On the left side, a new entry TEST is added below the database icon. The operations and results of the statements are shown below the script. Screenshot: see the result

Disconnect

Click on [Disconnect]: Disconnect icon to close the connection.

End

Close the console window. For more information, see the Tutorial.

Từ khóa » H2 Ui