Questions tagged [h2]

H2 is a relational database management system written in Java. It can be embedded in Java applications or run in the client-server mode. H2 supports regular disk-based as well as in-memory databases.

The software is available as open source software under modified versions of the Mozilla Public License or the original Eclipse Public License. The main features of H2 are:

  • Very fast, open source, JDBC API
  • Embedded and server modes; in-memory databases
  • Browser based Console application
  • Small footprint: around 2 MB jar file size

The main author of H2 is Thomas Mueller, who also developed the Java database engine Hypersonic SQL. The name H2 stands for Hypersonic 2, however H2 does not share code with Hypersonic SQL or HSQLDB.

Wiki

Issues

API

4948 questions
19
votes
2 answers

Why use SQLite over H2 for java application

I need to use an embedded database in my java application that will be run in a Linux device. The application uses Hibernate and derby database. This is not a Android application. Due to slow performance of the database, we are looking for a better…
Srinivasan
  • 399
  • 1
  • 2
  • 9
19
votes
4 answers

H2 SQL database - INSERT if the record does not exist

I would like initialize a H2 database, but I am not sure if the records exist. If they exist I don't want to do anything, but if they don't exist I would like to write the default values. Something like this: IF 'number of rows in ACCESSLEVELS' =…
szedjani
  • 550
  • 2
  • 6
  • 21
19
votes
1 answer

Creating a table in h2 database using predefined sequence for primary key

I am trying to create a table in an H2 database. How do I specify that the primary key should be generated from a sequence that has been created? The sequence is called group_seq, and I created it using this statement: CREATE SEQUENCE GROUP_SEQ; So…
user1154644
  • 4,491
  • 16
  • 59
  • 102
19
votes
2 answers

H2 Database multiple connections

I have the following issue: Two instances of an application on two different systems should share a small database. The main problem is that both systems can only exchange data through a network-folder. I don't have the possibilty to setup a…
D-rk
  • 5,513
  • 1
  • 37
  • 55
18
votes
3 answers

How to access in-memory h2 database from Intellij IDEA

In Spring Boot project I am trying to see in-memory tables from my IDE. How to access in-memory h2 database from Intellij IDEA. Here is a snippet from my application.yml: h2: datasource: url: jdbc:h2:mem:mydb username:…
valijon
  • 1,304
  • 2
  • 20
  • 35
18
votes
2 answers

H2 update with join

As development DB I am using MySQL, and for tests I am using H2 database. The following script works in MySQL very well, but it is fails on H2. UPDATE `table_a` JOIN `table_b` ON `table_a`.id=`table_b`.a_id SET `table_a`.b_id=`table_b`.id In the…
Squeez
  • 919
  • 2
  • 12
  • 30
18
votes
1 answer

How to create stored procedure using H2 database?

Has anyone tried to create stored procedures using the H2 database?
user351687
  • 241
  • 1
  • 3
  • 6
17
votes
7 answers

Error in Intelij h2 config The write format 1 is smaller than the supported format 2, spring boot app

While trying to connect H2 data source by URL in Intelij, following error occurs: The write format 1 is smaller than the supported format 2
Tohid Makari
  • 1,700
  • 3
  • 15
  • 29
17
votes
6 answers

Docker compose Invalid volume destination path: '.' mount path must be absolute

Following is my dockerfile that works to run the H2 Database: I want to create a docker compose file for this. FROM klousiaj/oracle-java:7.79 MAINTAINER J.P. Klousia ENV DOWNLOAD http://www.h2database.com/h2-2016-10-31.zip ENV DATA_DIR…
Shan Khan
  • 9,667
  • 17
  • 61
  • 111
17
votes
2 answers

Generate UUID values by default for each row on column of UUID type in H2 Database Engine

In the H2 database, on a table with a column of UUID data type, how do we specify that we want H2 to generate a UUID value by default when an INSERT omits that field? I know how to generate a UUID. I have read the Question, How to insert a specific…
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
17
votes
17 answers

Spring Boot JPA H2 Console not running, application.properties file ignored

The Spring Boot guide says I can get the H2 console but it's not working for me. http://localhost:8080/h2/ Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Oct 26 12:31:46 BST…
clickcell
  • 439
  • 3
  • 6
  • 20
17
votes
1 answer

H2 Database vs SQLite on Android

Because of the lack of Unicode support on the embedded SQLite database in Android I am mostly interested in performance and stability of H2 Database vs Android SQLite Are you guys using it? Should I be aware of any H2 database shortcomings?
Eduardo
  • 2,327
  • 5
  • 26
  • 43
17
votes
4 answers

h2 in-memory tables, remote connection

I am having problems with creating an in memory table, using H2 database, and accessing it outside of the JVM it is created and running in. The documentation structures the url as jdbc:h2:tcp:///mem: I've tried many combinations,…
Carolyn
  • 171
  • 1
  • 1
  • 3
17
votes
3 answers

IF function in H2 for MySQL compatibility

I'm using H2 (with MySQL compatibility mode) to write some automated tests against our software that uses MySQL. Unfortunately, it seems like H2 does not have have the IF function that many of our queries use. Short of rewriting our application…
vicsz
  • 9,552
  • 16
  • 69
  • 101
17
votes
1 answer

Error using Hibernate with H2 in memory database

I'm working with Hibernate. How can I configure my persistence.xml to have an H2 in-memory database? My persistence.xml is:
andPat
  • 4,153
  • 7
  • 24
  • 36