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
14
votes
1 answer

Long string data type in H2 databases

I am trying to create an H2 database to manage some text clippings. One of the fields will contain a large string that may be hundreds and, in a few instances, thousands of words long. Ideally I would not want to limit the size of this field at the…
14
votes
1 answer

Quick SQL question: Correct syntax for creating a table with a primary key in H2?

I'm currently starting a new Java application using the H2 database, but I have some confusion about basic SQL use for creating tables. How do I make a table of entries (strings) each with unique, auto-incrementing, non-null, integer primary keys? …
Daddy Warbox
  • 4,500
  • 9
  • 41
  • 56
14
votes
3 answers

How to fix error with H2 plugin (version 1.4.200) when run Spring tests: JdbcSQLSyntaxErrorException: Column "start_value" not found

I had to update Spring Boot starter from 2.1.4.RELEASE to 2.2.6.RELEASE, but now the integration tests are failing. My tests are in Groovy, my application is written in Java. They runned well with previous Spring version (2.1.4). After the update…
Rita Pissarra
  • 561
  • 5
  • 10
14
votes
4 answers

Access mem or fs database tables using H2 console

I'm trying to access my application's tables in Play! Framework, but I can't find it using the console. For instance, I have two entity models: Address and Campus. I can create objects and save normally, but I would like to see the changes in fs or…
Sedir Morais
  • 153
  • 1
  • 5
14
votes
4 answers

reactive repository throws exception when saving a new object

I am using r2dbc, r2dbc-h2 and experimental spring-boot-starter-data-r2dbc implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1' implementation 'org.springframework.data:spring-data-r2dbc:1.0.0.RELEASE' //…
lapots
  • 12,553
  • 32
  • 121
  • 242
14
votes
2 answers

Tests in Spring Boot with database H2

I am trying to run tests on a Spring Boot api with H2 database in the test, however, when trying to run the tests the system is using the application.properties in the main resource instead of the test. I tried naming the file as…
user2831852
  • 535
  • 2
  • 7
  • 22
14
votes
4 answers

Why am I getting JdbcSQLException (non-hex characters) with my H2 database / Spring boot application?

So the short version, I'm guessing I've some sort of character encoding issue, or the DB is storing/returning the date in a format Hibernate/Spring-jpa doesn't like for some reason. But I'm jiggered if I can work out what's going wrong! Using…
DaFoot
  • 1,475
  • 8
  • 29
  • 58
14
votes
1 answer

Spring-boot populate H2 database with schema.sql and data.sql

I set up Spring-boot to work with H2 in-memory database application.properties file is in the /config directory and it looks like, this file is…
user3687431
  • 283
  • 2
  • 3
  • 10
14
votes
2 answers

H2 - How to create a database trigger that log a row change to another table?

How to create a database trigger that log a row change to another table in H2? In MySQL, this can be done easily: CREATE TRIGGER `trigger` BEFORE UPDATE ON `table` FOR EACH ROW BEGIN INSERT INTO `log` ( `field1` `field2`, …
Pinch
  • 2,768
  • 3
  • 28
  • 44
14
votes
2 answers

In H2 Database, add index while table creation in single query

I am trying to create table having different indexes with single query but H2 gives Error for example: create table tbl_Cust ( id int primary key auto_increment not null, fid int, c_name varchar(50), INDEX (fid) ); but this gives error as…
user4099884
14
votes
5 answers

"Create table if not exists" - how to check the schema, too?

Is there a (more or less) standard way to check not only whether a table named mytable exists, but also whether its schema is similar to what it should be? I'm experimenting with H2 database, and CREATE TABLE IF NOT EXISTS mytable (....) statements…
Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
14
votes
1 answer

Simple H2 and Hibernate/JPA

Simple test with H2 as the database, JPA and Hibernate. Gives no discerning error, but it does not persist the entity. For sure I am missing something extremely simple persistence.xml in META-INF/:
vlad dd
  • 155
  • 1
  • 1
  • 8
14
votes
1 answer

How to use a persistent H2 database in the Play Framework instead of in-memory

The H2 database used in the Java Todo List tutorial is the following: db.default.driver=org.h2.Driver db.default.url="jdbc:h2:mem:play" How do I modify the configuration file to use a persistent database as opposed to an in-memory version. Do I…
Brad
  • 9,113
  • 10
  • 44
  • 68
14
votes
4 answers

UnsupportedOperationException when merging an existing Hibernate model object?

After an upgrade from Hibernate 3 to 4, we're working through a few kinks that popped up along the way. One that has us particularly stumped is an UnsupportedOperationException, where an existing object is pulled from the database, tweaked, and…
Craig Otis
  • 31,257
  • 32
  • 136
  • 234
13
votes
1 answer

H2 database CREATE TABLE with constraint

I have two SQL statements: CREATE TABLE legs(legid INT PRIMARY KEY AUTO_INCREMENT NOT NULL, playerid1 INT NOT NULL REFERENCES players(playerid), playerid2 INT NOT NULL REFERENCES players(playerid), …
c24w
  • 7,421
  • 7
  • 39
  • 47