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
245
votes
27 answers

H2 in-memory database. Table not found

I've got a H2 database with URL "jdbc:h2:test". I create a table using CREATE TABLE PERSON (ID INT PRIMARY KEY, FIRSTNAME VARCHAR(64), LASTNAME VARCHAR(64));. I then select everything from this (empty) table using SELECT * FROM PERSON. So far, so…
Jorn
  • 20,612
  • 18
  • 79
  • 126
127
votes
14 answers

Spring Boot default H2 jdbc connection (and H2 console)

I am simply trying to see the H2 database content for an embedded H2 database which spring-boot creates when I don't specify anything in my application.properties and start with mvn spring:run. I can see hibernate JPA creating the tables but if I…
Aaron Zeckoski
  • 5,016
  • 8
  • 25
  • 48
115
votes
7 answers

Can I have H2 autocreate a schema in an in-memory database?

(I've already seen the H2 database In memory - Init schema via Spring/Hibernate question; it is not applicable here.) I'd like to know if there's a setting in H2 that will allow me to auto-create a schema upon connecting to it. If it helps, I'm…
Laird Nelson
  • 15,321
  • 19
  • 73
  • 127
102
votes
10 answers

Frontend tool to manage H2 database

How to use H2 database's integrated managment frontend? For operations such as create table, alter table, add column, and so on.
blow
  • 12,811
  • 24
  • 75
  • 112
96
votes
11 answers

View content of H2 or HSQLDB in-memory database

Is there a way to browse the content of an H2 or an HSQLDB in-memory database for viewing? For example, during a debugging session with Hibernate in order to check when the flush is executed; or to make sure the script that instantiates the DB gives…
jplandrain
  • 2,278
  • 4
  • 24
  • 24
95
votes
2 answers

Which is better H2 or HSQLDB?

HSQLDB 2.0 is soon to be released. I wonder if it will outperform H2 since, as far as I know, most users prefer H2 than HSQLDB. I am interested in the MVCC support of HSQLDB 2.0. I have learned that MVCC on H2 is still experimental. With regards to…
dexter
  • 1,869
  • 2
  • 14
  • 13
86
votes
5 answers

Connect to H2 database using IntelliJ database client

My Grails app uses a h2 database in dev mode (the default behaviour for Grails apps). The DB connection settings in DataSource.groovy are dataSource { pooled = true jmxExport = true driverClassName = "org.h2.Driver" username = "sa" …
Dónal
  • 185,044
  • 174
  • 569
  • 824
80
votes
6 answers

How to configure spring-boot to use file based H2 database

I have successfully created a spring boot application that uses the H2 embedded database in-memory. I would now like to change this to a file based version that will persist. I have tried just changing the spring.datasource.* properties in my…
bitboy
  • 903
  • 1
  • 6
  • 6
78
votes
5 answers

auto increment ID in H2 database

Is there a way to have an auto_incrementing BIGINT ID for a table. It can be defined like so id bigint auto_increment but that has no effect (it does not increment automatically). I would like to insert all fields but the ID field - the ID field…
eriq
  • 1,524
  • 3
  • 13
  • 22
75
votes
6 answers

How to find rows in one table that have no corresponding row in another table

I have a 1:1 relationship between two tables. I want to find all the rows in table A that don't have a corresponding row in table B. I use this query: SELECT id FROM tableA WHERE id NOT IN (SELECT id FROM tableB) ORDER BY…
Steve McLeod
  • 51,737
  • 47
  • 128
  • 184
74
votes
3 answers

How in H2DB get sql dump like in MySql?

I have H2DB database which stores data in files. I have 3 files: test.18.log.db, test.data.db, and test.index.db. I want get SQL dump file like when I use mysqldump. Is it possible?
palych063
  • 1,059
  • 2
  • 9
  • 7
73
votes
4 answers

Executing script file in h2 database

First of all I would like to say am new to h2 database. I need to execute a sql script file in h2 database. I have a script file test.sql and I want to execute this in h2 database. Is it possible?
Kamalam
  • 1,254
  • 6
  • 18
  • 32
66
votes
4 answers

H2-Console is not showing in browser

I am working on SpringBoot api and using H2 database with following property settings. …
TAB
  • 1,944
  • 8
  • 28
  • 45
60
votes
17 answers

H2 database error: Database may be already in use: "Locked by another process"

I am trying to use the H2 database from a Java application. I created the database and its tables through the H2 Console and then I try to connect from Java using Connection con = DriverManager.getConnection("jdbc:h2:~/dbname", "username",…
Vasilis
  • 2,721
  • 7
  • 33
  • 54
60
votes
4 answers

problem with INIT=RUNSCRIPT and relative paths

I use maven conventions for source paths (src/main src/test) and i have my sql scripts in src/main/resources/scripts. I want to run my app with H2 memory and i'd like to use the jdbc url to initialize my db : database.url=jdbc:h2:mem:;INIT=RUNSCRIPT…
Maxime ARNSTAMM
  • 5,274
  • 10
  • 53
  • 76
1
2 3
99 100