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
22
votes
3 answers

How to connect to specific Schema in H2

So I have created a few schema in H2. How can I connect to a specific schema in H2 For example when I need to connect to a specific schema in SQL Server I have below JDBC…
Acewin
  • 1,657
  • 4
  • 17
  • 36
21
votes
2 answers

Saving in-memory H2 database to disk

How can I save/load full embedded h2 in-memory database to some file or directory in binary mode for faster loading. I want to use this for caching data so I don't have to run all the lines of create table/insert clauses every time.
mikkom
  • 3,521
  • 5
  • 25
  • 39
21
votes
6 answers

Why I can't get the org.h2.Driver? I use maven

I face a problem about connecting to H2 this is my pom.xml: 4.0.0 . dbConnection Db Connection war
joker
  • 211
  • 1
  • 2
  • 5
21
votes
1 answer

File based h2 persisted but not loaded in Spring Boot

I made a small application based on Spring Boot: spring-boot-starter-web spring-boot-starter-data-jpa The application has simply one domain class Post.java. Accordingly there is a RestController and a DAO. The data is supposed to be persisted in a…
Phil
  • 578
  • 2
  • 5
  • 15
21
votes
2 answers

Why we need a connection pooling for JDBC?

What are the benefits of using a JDBC connection pooling tool like DBCP or c3p0 ? in case of a small CRUD application with one user, can we just create one connection session as a singleton ? PS: I'm building a small javafx application back-ended…
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
20
votes
3 answers

Any real world experience with H2 database?

Has anybody out there got any real world experience with the H2 database? I'm interested in: performance stability bugs
David Plumpton
  • 1,929
  • 23
  • 31
20
votes
6 answers

How to fix: Embedded H2 Database "NonTransientError: Unable to read the page at position" error?

I am creating a JavaFX program with an embedded H2 database that will be used to handle user logins and passwords. Using Intellij Ultimate, I have a database that I can run from the toolbar. In addition, I am almost certain I have the correct JDBC…
Suede
  • 416
  • 2
  • 5
  • 16
20
votes
2 answers

H2 db not accessible at localhost:8080/h2-console when using webflux

H2 db is not accessible at localhost:8080/h2-console when using webflux. I read somewhere that this is available only when developing a Servlet-based application. But I am using Webflux with Netty. So is there a way to see the h2 console in such an…
Krishnakumar R
  • 362
  • 2
  • 18
20
votes
11 answers

H2 not creating/updating table in my Spring Boot app. Something's wrong with my Entity?

I want to keep some data in H2 database by making a CRUD repository, using Hibernate. I can't get the database to store my entries whatsoever. Currently, I'm trying to achieve that during updating the db by making a sample entry. Entry is looking…
VapeKop
  • 349
  • 2
  • 4
  • 13
20
votes
3 answers

How to show content of local h2 database(web console)?

Recently I joined a new team and here guys use h2 for stub service. I was wondering whether I can show the content of this database using web interface. At work it is available by going to localhost:5080 I have a project where I use h2 database, but…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
20
votes
4 answers

H2 - How to truncate all tables?

I assume there is a way of doing this from code, at least some good workaround. Please consider that I do not want to delete all tables (I've seen this command), just to delete rows from them but to keep existing schema and all constraints. Maybe I…
Filip
  • 2,244
  • 2
  • 21
  • 34
20
votes
2 answers

H2: how to set default schema and database?

I am using Liquibase for my database updates and testing it against H2. I am using Spring to configure the properties. I use dataSource.setUrl("jdbc:h2:mem:test_common"); to connect to test_common database, but it did not work out. I realized that…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
19
votes
2 answers

How to trace SQL requests for H2 in-memory databases?

How can I trace SQL requests for H2 in-memory embedded databases? The documentation says the trace file is located in the same directory as the database file, but for in-memory embedded database I have no database directory (under Windows). I tried…
user1274500
  • 195
  • 1
  • 1
  • 6
19
votes
3 answers

Does Spring embedded database support different SQL dialects?

H2 has a range of compatibility modes for various other databases such as MS SQL Server, MySQL, Oracle, etc that support different SQL dialects. However, when setting up an embedded database in Spring I do not find any corresponding setting. Does…
matsev
  • 32,104
  • 16
  • 121
  • 156
19
votes
1 answer

How to use "on update CURRENT_TIMESTAMP" in H2 database with JUnit?

I want my entity to have a modification timestamp whenever it is updated. mysql supports this using the following definition: @Entity public class MyTable { @Column(columnDefinition = "TIMESTAMP default CURRENT_TIMESTAMP on update…
membersound
  • 81,582
  • 193
  • 585
  • 1,120