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
58
votes
7 answers

View content of embedded H2 database started by Spring

I would like to view in a web browser the content of the H2 database started by Spring thanks to the following configuration:
tduchateau
  • 4,351
  • 2
  • 29
  • 40
57
votes
6 answers

Reset Embedded H2 database periodically

I'm setting up a new version of my application in a demo server and would love to find a way of resetting the database daily. I guess I can always have a cron job executing drop and create queries but I'm looking for a cleaner approach. I tried…
javydreamercsw
  • 5,363
  • 13
  • 61
  • 106
56
votes
2 answers

How to use a path relative to project root to H2 db-file configuration with Play Framework 2.4?

We're developing a Play 2.4 application (Java API). For dev purposes, we'd like to use a persistent H2 database with DB file path relative to the project root directory. In How to use a persistent H2 database in the Play Framework instead of…
Touko
  • 11,359
  • 16
  • 75
  • 105
55
votes
12 answers

How to map a JSON column with H2, JPA, and Hibernate

I use in application MySQL 5.7 and I have JSON columns. When I try running my integration tests don't work because the H2 database can't create the table. This is the error: 2016-09-21 16:35:29.729 ERROR 10981 --- [ main]…
earandes
  • 553
  • 1
  • 4
  • 5
54
votes
3 answers

Where does H2's Embedded Databases Store the data?

So I just recently started learning about how databases work, how to use SQL ect. and decided to start implementing an embedded database into my Java application (specifically the H2 database) and seemed to work fairly well on the computer I was…
Sammy Guergachi
  • 1,986
  • 4
  • 26
  • 52
51
votes
9 answers

What is the default username and password for h2 when there's nothing explicit in JDBC?

From a program, I created a H2 database without specifying any user or password in the JDBC URL. Now I'm trying to access that database with the Script tool. The doc says to use -user sa in the default case. That doesn't work, and it still doesn't…
bmargulies
  • 97,814
  • 39
  • 186
  • 310
50
votes
8 answers

Timeout error trying to lock table in h2

I get the following error under a certain scenario When a different thread is populating a lot of users via the bulk upload operation and I was trying to view the list of all users on a different web page. The list query, throws the following…
user339108
  • 12,613
  • 33
  • 81
  • 112
49
votes
31 answers

springboot 2.3.0 while connecting to h2 database

In Springboot 2.3.0.RELEASE I am getting the the following error while connecting to h2 database in the console Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments)…
ramesh b
  • 591
  • 1
  • 4
  • 3
49
votes
4 answers

Why does the H2 console in Spring Boot show a blank screen after logging in?

I'm using Spring Boot 1.4.1 with the H2 database. I have enabled the H2 console as described in the reference guide by adding the following lines to my application.properties file: spring.h2.console.enabled=true spring.h2.console.path=/h2 When I…
pacoverflow
  • 3,726
  • 11
  • 41
  • 71
48
votes
3 answers

Defining a Foreign key constraint in H2 Databases

I am new in coding so I made a tables in SQL server and it worked, so i used the same command in H2 and it said I have a syntax problems with the second table, someone can help? CREATE TABLE TOURISTINFO( TOURISTINFO_ID INT PRIMARY KEY, NAME…
l3kov
  • 481
  • 1
  • 4
  • 4
44
votes
4 answers

Spring Data JPA Unable to locate Attribute with the given name

I was trying to use Spring Data JPA on Spring Boot and I kept getting error, I can't figure out what the problem is: Unable to locate Attribute with the the given name [firstName] on this ManagedType…
smned
  • 663
  • 1
  • 6
  • 19
44
votes
3 answers

Spring’s embedded H2 datasource and DB_CLOSE_ON_EXIT

For unit tests (call them integration tests if you want) I have configured an embedded database in my Spring config like so:
Michael Piefel
  • 18,660
  • 9
  • 81
  • 112
43
votes
16 answers

java ClassNotFoundException for org.h2.Driver

I am trying to use H2 to connect to a database in Java (using Eclipse as the IDE). The sample does (below) throws a ClassNotFoundException. The thing is, I did add the h2 jar file to the system CLASSPATH. I have even checked it's there several times…
Ashton Wilkins
  • 431
  • 1
  • 4
  • 3
43
votes
4 answers

Spring configuration for embedded H2 database for tests

What does your Spring configuration for integration tests look like using an embedded h2 datasource and, optionally, JUnit? My first try with a SingleConnectionDataSource basically worked, but failed on more complicated tests where you need several…
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139
43
votes
4 answers

Initialize database without XML configuration, but using @Configuration

I would like to know how to initialize a database without having to create an XML file. I already use this kind of initialization that works fine, but in my current case I don't want to create an XML:
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419