h2

Any ideas for persisting H2 Database In-Memory mode transaction?

微笑、不失礼 提交于 2019-12-05 01:09:56
问题 The following code for H2 database with "in-memory mode" runs perfectly fine until connection is open or VM is running. But H2 db loses data when connection is closed or when VM shutdown takes place. Is there any other way to persist data across multiple startup-shutdown/online-offline cycles ? One way would be to create diskbased replica of in-memory database by tracking DDLs and DMLs issued from application and a sync process in background that checks for integrity of data on disk and

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

六眼飞鱼酱① 提交于 2019-12-05 00:40:38
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 apparently only check for the table´s name . I would expect to get an exception if there's a table with the given name, but different schema. CREATE TABLE IF NOT EXISTS ... is not a standard SQL code. The thing to do is to check if the table is already in the catalogue. For instance, in Java you may do something like: connection.getMetaData()

Defining a Foreign key constraint in H2 Databases

我的未来我决定 提交于 2019-12-04 23:50:51
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 VARCHAR(25) NOT NULL, NATIONALITY VARCHAR(15) NOT NULL ) CREATE TABLE PLANETICKETS( DESTINATION VARCHAR(10) NOT NULL, TICKETPRICE NUMERIC(8,2) NOT NULL, TOURISTINFO_ID INT FOREIGN KEY REFERENCES TOURISTINFO ) The error is Syntax error in SQL statement "CREATE TABLE PLANETICKETS( DESTINATION VARCHAR(10) NOT NULL, TICKETPRICE NUMERIC(8,2) NOT NULL,

Dropping unique constraint for column in H2

我是研究僧i 提交于 2019-12-04 21:42:41
问题 I try to drop unique constraint for column in h2, previously created as info varchar(255) unique . I tried: sql> alter table public_partner drop constraint (select distinct unique_index_name from in formation_schema.constraints where table_name='PUBLIC_PARTNER' and column_list='INFO'); But with no success (as follows): Syntax error in SQL statement "ALTER TABLE PUBLIC_PARTNER DROP CONSTRAINT ([*]SELECT DISTI NCT UNIQUE_INDEX_NAME FROM INFORMATION_SCHEMA.CONSTRAINTS WHERE TABLE_NAME='PUBLIC

Multiple independent H2 databases within one JVM

吃可爱长大的小学妹 提交于 2019-12-04 19:34:31
Is it possible to start up and shut down multiple H2 databases within a JVM? My goal is to support multi-tenancy by giving each user/account their own database. Each account has very little data. Data between the accounts is never accessed together, compared, or grouped; each account is entirely separate from the others. Each account is only accessed briefly once a day or a few times a month. So there are few upsides to housing the data together in a single database, and some serious downsides. So my idea is that when a user logs in for a particular account, that account’s database is loaded.

IF function in H2 for MySQL compatibility

倖福魔咒の 提交于 2019-12-04 18:29:38
问题 I'm using H2 (with MySQL compatibility mode) to write some automated tests against our software that uses MySQL. Unfortunately, it seems like H2 does not have have the IF function that many of our queries use. Short of rewriting our application queries with something like DECODE, is their a good way to create the if function, say as an Alias? The error that I'm getting: WARNING: Failed to execute: SELECT IF(true,'TRUE!!','FALSE!!!') because: Function "IF" not found; SQL statement: 回答1: Ended

How to use H2 as embedded database in Postgres-compat mode, from jruby/rails

你说的曾经没有我的故事 提交于 2019-12-04 17:58:57
I'd like to launch a jruby/rails app to use Postgres. But I'd like to use H2 in Postgres compatibility mode when running in development and test. Its no problem bringing up the app in H2, or in postgresql, but how do I configure to run the postgresql adaptor, using an embedded H2 database? For example: something like this: database.yml development: # adapter: jdbch2 # database: db/development/database adapter: postgresql encoding: unicode database: database # driver: org.h2.Driver url: jdbc:h2:~/db/development;MODE=PostgreSQL test: ... Gemfile: ... gem 'activerecord-jdbch2-adapter' #gem 'jdbc

Play! framwork: running `h2-browser` works, but the webpage is not available

不问归期 提交于 2019-12-04 16:03:54
When I run the command activator h2-browser it opens the browser with the following url: 192.168.1.17:8082 But I get (using Chrome): This webpage is not available The weird thing is it actually worked before. The only thing I changed since then is the JAVA_OPTS in order to enable debugging. I reinstalled Java and I think now there's no environment variable JAVA_OPTS . Anyway, why is it happening? Update What is even more weird is that when I press view-source I get a webpage with this announcement (this is part of the webpage): <h1>Welcome to H2</h1> <h2>No Javascript</h2> If you are not

Corda: How to implement hierarchical relationships between state data persisted to H2

笑着哭i 提交于 2019-12-04 15:17:35
Summary I've adapted the basic Token Issuance Corda Bootcamp application to demonstrate this issue. I want to create a bidirectional mapping between TokenStates and TokenChildren where the relationship is one-to-many. What are the best practices for persisting hierarchical data? Is it possible to implement this using JPA annotations in state schemas? I have one state - TokenState , that contains some arbitrary data as well as a Collection of objects with the class TokenChild . The purpose of this list is to facilitate a one-to-many relationship between the records in H2. The state's associated

How do I determine if an H2 database file lock exists?

谁说我不能喝 提交于 2019-12-04 14:59:53
For reasons that I will not explain (because people will direct their responses at the other topic, instead of my problem at hand), I need to know how to determine whether or not my H2 database is locked. Using Java code, how do I determine whether or not the lock file exists on my database? For others reading this question I need to explain why you you shouldn't do it yourself, and let the database detect itself whether it is locked or not. First of all, database file locking is an implementation detail that can and will change in future versions of the database. Then, there is a race