> I'm using the Spring framework
I didn't use the Spring framework so far so I can't help you here.
> My second question is about how to initialize the database schema. In
> HSQLDB, it seemed like in-memory databases still generated scripts
> that would automatically initialize the database schema when it was
> restarted.
There are different kinds of in-memory databases. In HSQLDB, by
default the data is kept fully in memory because the default table
type is 'in-memory table'. In H2 the default table type is 'persistent
table' (H2 also support 'in-memory table' however it is not exactly
the same as in HSQLDB).
> I haven't seen any mention of similar functionality
> for H2
See
http://www.h2database.com/html/features.html#connection_modes
http://www.h2database.com/html/features.html#database_url
http://www.h2database.com/html/features.html#memory_only_databases
http://www.h2database.com/html/grammar.html#setdefaulttabletype
> Should I just create a schema
> creation script and run that using the above datasource as a first
> step?
It depends if you want to use 'memory only databases'.
I suggest you read the docs first.
Regards,
Thomas
Thanks for the reply and pointers to the docs. I have read through those
and understand the ways to instantiate the in-memory database. I am looking
for an instance where all data is contained in-memory (for the 'high
performance operations') and am able to start the instance of the database
using the named, in-memory datasource url (jdbc:h2:mem:example). When doing
this, I guess my question is will that database always be initialized with
no user schema? I understand that it will have no data, but are there ways
to persist the schema?
Actually, I just read through the HSQLDB documentation and saw that the
contents as well as the structure are written to the <dbname>.script file.
So if I'm looking for the fastest performance (for reads, inserts, and
updates) and I can reconstruct the contents each time the database is
started myself, would you recommend the in-memory database only and then on
each startup, run a script to create all tables, indexes, etc?
Also, for performance, if I'm looking for the fastest read/insert/update
operations and will need to transaction wrap updates/inserts and I'm not
concerned about persisting it to disk, is H2 better suited for that
application than HSQLDB?
Thanks so much for your advice and for all the work into H2 (and HSQLDB)!
Gary
----- Original Message -----From: MingfaiSent: Sunday, April 06, 2008 8:19 AMSubject: Re: Using in-memory db with Spring
> Oh - also, the data being stored will grow to be pretty large. Probably
> about 2 GB of data.
I don't think you should use an in-memory database then. There is
quite a large overhead for in-memory databases. I suggest you try
using regular persistent databases first, and maybe create some of the
(smaller) tables in memory using CREATE MEMORY TABLE for performance.
Regards,
Thomas
Hi mingfai,
I am a newbie and want to use H2 in Server Mode along with spring.
If i where using these for not in memory database and in server mode,
do i just have to change the url to "jdbc:h2:~/
perfomanceevaluation;DB_CLOSE_DELAY=-1"? and how to make sure that
server is shutdown when the H2 database is running in Server Mode?Regards,
TiKi