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

h2 leaving lock file even though only create one connection and immediately disconnect

My application is using an in memory h2 database with Hibernate, I was noticing that even after closing the application the h2 lock file remained. This occurred even if I started the application and then immediately without doing anything much…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
2
votes
1 answer

H2 - sum per day

I need help with creating a query. Currently it looks like this SELECT COUNT(*) AS ALERTS, EXTRACT (YEAR FROM DATE) AS YEAR, EXTRACT (MONTH FROM DATE) AS MONTH, EXTRACT (DAY FROM DATE) AS DAY, HOST, ALERTLEVEL FROM …
user955732
  • 1,330
  • 3
  • 21
  • 48
2
votes
1 answer

QueryDSL: How to insert or update?

I'm trying to implement https://stackoverflow.com/a/16392399/14731 for a table called "Modules" using QueryDSL. Here is my query: String newName = "MyModule"; QModules modules = QModules.modules; BooleanExpression moduleNotExists =…
Gili
  • 86,244
  • 97
  • 390
  • 689
2
votes
1 answer

Spring + JPA + Hibernate Testing with H2 and @ContextConfiguration

I have a Spring + JPA + Hibernate application that I'm trying to test by subclassing code>AbstractJUnit4SpringContextTests. The class allows to specify the Spring context file using the @ContextConfiguration annotation. In this file, the database is…
Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
2
votes
2 answers

h2 with custom java alias and javac compiler issues in multi process environment

H2 database with custom function alias defined as: create alias to_date as $$ java.util.Date toDate(java.lang.String dateString, java.lang.String pattern) { try { return new…
maximdim
  • 8,041
  • 3
  • 33
  • 48
2
votes
2 answers

PHP connection to H2DB H2 database

How can I connect PHP to an H2 database, so far I tried starting the embedded server with a $ java -cp h2-1.3.172.jar org.h2.tools.Server Web Console server running at http://127.0.1.1:8082 (others can connect) TCP server running at…
dendini
  • 3,842
  • 9
  • 37
  • 74
2
votes
2 answers

Is the H2 automatic mixed mode the correct way to access a database on a network share from different clients?

I have the same scenario as this one: H2 Database multiple connections. It's the classic "Microsoft Access database on network share" approach. I have an application that should be installed on several clients within a LAN. During the installation,…
Reto Höhener
  • 5,419
  • 4
  • 39
  • 79
2
votes
1 answer

sql-maven-plugin throws SQL syntax error for H2 stored procedure definition

I try to install a stored procedure in an h2 database (v. 1.3.170) using the sql-maven-plugin version 1.5. The offending SQL statement looks like this: CREATE ALIAS GET_DATA AS $$ ResultSet getData(Connection conn, String id) { return null; …
tomsen_san
  • 31
  • 4
2
votes
1 answer

How to store and convert IP addresses in H2?

What is the best field type and length for storing IP (IPv4) addresses in a H2 database? The input is text e.g. "X.X.X.X". In MySQL there are some handy functions for converting IP data: INET_ATON and INET_NTOA Are there any equivalents in H2?
aviad
  • 8,229
  • 9
  • 50
  • 98
2
votes
1 answer

JUnit tests with h2 database behave strangely

I wrote several JUnit test classes, in a maven project that uses JDBC to connect to a h2 database. I have 8 test classes. When I run All tests with IntelliJ, I have a JDBC error (on the last test class :…
Saffron
  • 682
  • 6
  • 14
2
votes
1 answer

H2 - Why GROUP_CONCAT rejects rows with NULL values?

Run this script: drop table if exists foo cascade; create table foo( id int NOT NULL auto_increment, start date NOT NULL, end date ); insert into foo(start,end) values('2007-01-01', '2007-12-31'); insert into foo(start,end)…
Stephan
  • 41,764
  • 65
  • 238
  • 329
2
votes
1 answer

Creating an installation for a java project with H2 embedded databae

I created a java project that uses a database to retrieve, edit, and save data. I finished the project using Netbeans and now I want to create an installation out of the project. To do so, I want to include the database to be installed along with…
Brute Force
  • 464
  • 4
  • 15
2
votes
1 answer

H2 Database Update multiple columns

Good Day, I am trying to figure out how to update multiple columns in h2 database. Single column is easy like this: UPDATE TABLENAME SET COLUMN1='X' WHERE ID='2' But I want to update COLUMN2 and COLUMN3 also. How do i do this?!!
soulslicer0
  • 69
  • 2
  • 8
2
votes
0 answers

Embedded Jetty H2 JNDI Datasouce - javax.naming.NameNotFoundException; remaining name

I'm trying to setup a JNDI datasource for H2 database using Jetty Web Server; I have un-commented plus config in start.ini of Jetty and also added Configurations to jetty.xml as per Jetty documentation and created a jetty-web.xml which configures…
FiendFyre
  • 157
  • 3
  • 17
2
votes
1 answer

Unable to view recently inserted results in H2

I'm using the H2 Database system for a small java project I'm working on. If I manually run the Queries, everything works as expected, but when I run my program, I get the following: Constructed: INSERT INTO library VALUES…
nlowe
  • 999
  • 4
  • 11
  • 26