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
28
votes
2 answers

Spring: H2 Database persistence

My…
SteveOhio
  • 569
  • 2
  • 8
  • 20
28
votes
9 answers

Tests fail when executed from maven but not from Intellij

I'm writing my unit tests using JUnit, PowerMock, Spring Test and an in-memory H2 database. When I run the tests from Intellij everything runs correctly. But when I run the tests from maven (either from Intellij or from the command line) they fail.…
Neets
  • 4,094
  • 10
  • 34
  • 46
27
votes
6 answers

Any idea on H2 (Oracle MODE) "Syntax error : SELECT NEXTVAL FROM[*] DUAL"?

I have the following error using H2 (v1.3.154) with Oracle mode :
Jerome VDL
  • 3,376
  • 4
  • 32
  • 33
27
votes
5 answers

How to add the mode=mysql to embedded H2 DB in Spring Boot 1.4.1 for @DataJpaTest?

I have some problems with using a schema.sql file to create my sql schema when executing a junit test while this schema contains mysql specific expression. I have to add the mode=mysql to the H2 url. For example something like…
Marco
  • 279
  • 1
  • 3
  • 3
26
votes
2 answers

Accessing play project database with h2-browser

I am having some trouble accessing the mem database via the h2-browser on a Play framework project. With the configuration below, that I think is the correct one (apparently not!) I am getting a h2-browser, but with no tables (beside schema, that…
nunos
  • 20,479
  • 50
  • 119
  • 154
25
votes
2 answers

Hibernate and H2 "Referential integrity constraint violation" for OneToMany bidirectional mapping

I have two simple beans--FatKid and Hamburgers. I need to be able to not only look up all of the hamburgers someone ate, but also who ate which particular hamburger. FatKid.java import java.util.List; import javax.persistence.CascadeType; import…
Kevin
  • 1,420
  • 2
  • 13
  • 11
25
votes
4 answers

How to back up the embedded H2 database engine while it is running?

I would like to build up an web application with H2 database engine. However, I still don't know how to back up the data while the database is running after reading this…
Winston Chen
  • 6,799
  • 12
  • 52
  • 81
25
votes
2 answers

Make H2 treat quoted name and unquoted name as the same

H2 seems to make a difference between name with quote and name without quote. Is there a way to make it treat them the same way? Here's the tests that I've done : CREATE TABLE test (dummy INT); CREATE TABLE "testquote" (dummy INT, "quotedDummy"…
Drahakar
  • 5,986
  • 6
  • 43
  • 58
24
votes
1 answer

H2 Database Postgres Mode Upsert

When H2 database is in Postgres Mode, how do I check if it supports following statement (upsert / on conflict) INSERT INTO event_log_poller_state (aggregate_type, consumer_group_id, value) VALUES (?, ?, ?) on conflict (aggregate_type,…
Tony Murphy
  • 711
  • 9
  • 22
24
votes
7 answers

Set default timezone H2 database

How can I explicitly set the time zone H2 should use? Now it gets the timezone to use from the underlying OS. I would assume there existed an extra parameter I would add to the connection string ala the one I have…
Thomas Vervik
  • 4,325
  • 9
  • 36
  • 64
23
votes
3 answers

Using Liquibase to initialize in-memory H2 for unit tests in Spring Boot application

I've used in-mem databases in Spring JPA tests many times, and never had a problem. This time, I have a bit more complex schema to initialize, and that schema must have a custom name (some of the entities in our domain model are tied to a specific…
cvnew
  • 570
  • 1
  • 7
  • 13
23
votes
2 answers

How do I allow multiple users to connect to my H2 database simultaneously?

I am using H2 for database management, and this is what I would like to do: I would like to allow multiple users to access a database at the same time. I've read a bit about "MULTI_THREADED=TRUE", "LOCK_FILE=NO", and "AUTO_SERVER=TRUE". I've also…
Ryan
  • 511
  • 1
  • 8
  • 18
23
votes
6 answers

spring hibernate .. H2 database - schema not found

I am trying to persist some data into the H2 database. but I keep getting the schema not found error message as below. Jan 02, 2014 8:55:51 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library…
user2180794
  • 1,425
  • 7
  • 27
  • 50
23
votes
4 answers

Convert MySQL script to H2

I have an init script for my MySQL database but for test purposes I wan't to use a H2 database. Anyone knows how to convert the file or at least has a list of the syntax differences ? thanks.
user1502150
  • 357
  • 1
  • 4
  • 11
22
votes
3 answers

Spring Boot 2 - H2 Database - @SpringBootTest - Failing on org.h2.jdbc.JdbcSQLException: Table already exists

Unable to test Spring Boot & H2 with a script for creation of table using schema.sql. So, what’s happening is that I have the following properties…
Tora Tora Tora
  • 973
  • 3
  • 18
  • 33