Embedded database H2 installation diagram

Source: Internet
Author: User

Introduction of H2 Database

The common open source database is: H2,derby,hsqldb,mysql,postgresql. Where H2 and hsqldb are similar, they are ideal for use as an embedded database, while most other databases require the installation of separate client and server side.

Advantages of H2:

1. H2 is written in pure Java, so it is not limited by platform.

2, H2 only a jar file, very suitable as an embedded database trial.

3. H2 provides a very convenient web console for manipulating and managing database content.

Second, H2 database download and installation

2.1, H2 database download

H2 database Download Address: http://www.h2database.com/html/download.html

After the download is complete, you get the compressed package as shown in the following illustration:

2.2, H2 Database installation

H2 database installation is very simple, directly download the compressed package can be uncompressed, as shown in the following figure:

In this way, the H2 database, even if the installation is complete

2.3. Test H2 Database

First, introduce the directory structure of the H2 database

H2

|---Bin

| |---h2-1.1.116.jar//H2 database jar Pack (drive is also inside)

| | |---h2.bat//windows console startup script

| | |---h2.sh//linux console startup script

| | |---h2w.bat//windows console startup script (without a black screen window)

|---The help documentation for the Docs//H2 database (with a H2 database manual)

---service//services are packaged through wrapper.

|---src//H2 database Source code

|---build.bat//windows build script

|---build.sh//linux build script

Run the H2.bat batch program to start the H2 database, as shown in the following illustration:

Open the browser, enter the address: http://localhost:8082 access to the H2 database of the Web Console, as shown in the following illustration:

The ability to see this interface shows that the H2 database is working properly.

Iii. simple use of H2 database

3.1, Login to H2 database Webconsole console

After the connection test passes, click the "Connect" button and log in to the webconsole of the test database, as shown in the following illustration:

3.2. Create a table

Copy the sample SQL script provided by the H2 database, as shown in the following illustration:

Execute the SQL script as shown in the following illustration:

SQL Script Execution Results:

When all is done correctly, you can see the created test table as shown in the following illustration:

3.3. Test database File storage location description

In the above operation, we connect the test database using the Jdbc:h2:~/test URL through JDBC, as shown in the following figure:

Then you create a test table in the test database and perform CRUD operations on the test table, so which directory does the file of the test database reside in, and here you need to explain what the symbol "~" means under the window operating system, Under the window operating system, the symbol "~" represents the user directory of the user currently logged into the operating system, so the file corresponding to the test database is stored in the user directory of the user logged into the operating system. For example, I am currently logged on to the operating system with an administrator user, so the database file for the test database can be found in the c:documents and Settingsadministrator.h2 directory, as shown in the following illustration:

3.4, create a new database

Clicking on the "Connect" button will allow you to enter the console of the GaCl database, as shown in the following illustration:

You can now see that H2 automatically creates a good GaCl database and GaCl users, and then you can find the database file for the GACL database in the E:H2 directory, as shown in the following illustration:

Similarly, we can create tables in the newly created GACL database and crud the tables as shown in the following illustration:

This is a simple introduction to the H2 database, and the next blog post will explain how to manipulate the H2 database in a Java program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.