h2

Embedding the Java h2 database programmatically

At the moment we use HSQLDB as an embedded database, but we search for a database with less memory footprint as the data volume grows. Derby / JavaDB is not an option at the moment because it stores properties globally in the system properties. So we thought of h2. While we used HSQLDB we created a Server-object, set the parameters and...

Detecting Virus Scanners

We've had problems with a virus scanner murdering the performance of our app by slowing down writes to an H2 db. So we'd like to be able to detect the presence of any virus scanner and alert the user of the potential problem. It would be part of a problem detection retue that would alert users to known performance factors specific to the...

How do I view a property in H2 SQL

How does one view a property with a SELECT query? I've got some properties that I need to see the value of in a running H2 DB. I've got the Console app up and running. ...

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? One of the most basic things to do, but I'm not sure offhand what the correct way to do i...

How to write a null safe compare "<=>" in pure SQL?

In Mysql there is a compare operator that is a null safe: <=>. I use this in my Java program when creating prepared statements like this: String routerAddress = getSomeValue(); String sql = "SELECT * FROM ROUTERS WHERE ROUTER_ADDRESS <=> ? "; PreparedStatement stmt = connection.prepareStatement(sql); stmt.setString(1, routerAddress); ...

Database tables for entries of another table?

I'm designing a new revision of my Java application (using an embedded H2 database) around a redesign of the way I'll be handling my data. Here's how I have it planned: Entries table- Entry ID Entry name Properties table- Property ID Property name (Individual property) value table- Value ID Entry ID (Value columns...) (Individua...

Problem with SQL query

Hello. Sorry, I couldn't provide a better title for my problem as I am quite new to SQL. I am looking for a SQL query string that solves the below problem. Let's assume the following table: DOCUMENT_ID | TAG ---------------------------- 1 | tag1 1 | tag2 1 | tag3 2 | tag2 3 ...

check combination of records in table

I have two arrays of values like X,Y,Z and 1,2 There is a table A with two columns.I want to validate that in table A records with all the combination exists irrespective of duplicates. e.g. X 1 Y 1 Z 1 X 2 Y 2 Z 2 Thanks in advance! ...

How to get start and end dates of current month

Hi, How to get start date and end dates in a query from database. Thanks, Lico ...

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 id desc id is the primary key in both tables. Apart from primary key indices, I also ha...

Start the H2 database in server mode via Spring

I'm trying to start the H2 database in server mode (I want it to run in a different process) via Spring. Currently I'm using java Runnable.exec to start the h2 database (using the command: "java -cp h2.jar org.h2.tools.Server") I know that there is a way to do it via Spring. I tried to add the following to the spring configuration, but ...

H2 database. How to convert date to seconds in sql?

Is there analog og the MySQL's time_to_sec() ? I heed to perform query like the following on H2 database: select * from order join timmingSettings on order.timmingSettings = timmingSettings.id where (order.time-timmingSettings.timeout) < current_timestamp ...

H2 database In memory - Init schema via Spring/Hibernate

I have a Spring/Hibernate application with H2 database and I have a few issues with configuring H2 to run in an embedded mode (in memory): 1. I want spring to start the H2 database so I created the following Spring beans: <bean id="org.h2.tools.Server" class="org.h2.tools.Server" factory-method="createTcpServer" init-method="sta...

Spring configuration for embedded H2 database for tests

What does your Spring configuration for a datasource with embedded h2 database that you use for integration (JUnit-)tests look like? My first try with a SingleConnectionDataSource basically worked, but failed on more complicated tests involving suspended transactions. You might start h2 in tcp based server mode as well, but this is proba...

How to back up the embedded H2 database engine while it is running?

I would like to build up an web application with H2 database engine. However, I still don't know how to back up the data while the database is running after reading this tutorial: http://www.h2database.com/html/tutorial.html#upgrade_backup_restore Does H2 output its stored file to somewhere in the file system? Can I just back up the ou...

Grails Hibernate H2 problem

hi, I have an application with two domain classes as follows: DomainA : PK, name DomainB : PK, FK (points to DomainA.PK), name. And when I try to list elements that belongs to DomainA using the DomainB.name as order factor, as follows: def listings DomainA.createCriteria().list(params) { PK{ order('name','asc') } }...

Starting an H2 Database Server from Maven?

Sorry if this question is nonsensical, I'm still wrapping my head around new concepts. Suppose I want to create and use an H2 database for my integration tests. Maven has a command to run tests: mvn test. Is there a way to tell maven to start an H2 database server for the tests and stop it when it's done? I imagine this working simil...

What is the sql query for this ?

Id Project_Id Activity_Time Username 1 100 2008-01-01 11:12:13 A 2 100 2008-01-01 00:00:00 B 3 500 2008-02-01 00:00:00 C 4 300 2008-02-03 00:00:00 D 5 500 2008-03-03 11:11:11 A 6 300 2008-04-04 00:00:00 D ...

Starting/stopping H2 with ant

Hi all I installed H2 on a Windows PC. I would start H2 from ant so that it can be automatically started/stopped during a test suite execution. How can I do this with ant? Have I to call .bat in ./service directory or what? I can't find any H2-ant-tasks library. Thanks ...

Relational Database (H2, Java): How do I constrain a foreign key to NOT match another foreign key in the same table?

Simple question. Just wondering if this can be done without me having to enforce this constraint manually in my Java code. These two foreign keys (together in the same table) both refer out to another table, but for each row, they must not be allowed to point to the same foreign item. link text ...