H2 Installation

Version 2.6 by Manuel Smeria on 2012/12/11

H2 is a fast, free, in memory or disc based java database.

This document assumes you know how to set up a database, and use it, so this just details how to use H2.

Changes to Hibernate.cfg.xml

There are two ways you can connect to your database, either via a server managed JDBC pool or by a hibernate managed pool.

When using a JDBC datasource

<property name="connection.datasource">java:comp/env/jdbc/XWikiDS</property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>

When letting hibernate manage your pools

<property name="connection.url">jdbc:h2:tcp://remotehost/xwiki23</property>
<property name="connection.username">xwiki</property>
<property name="connection.password">xwikipw</property>
<property name="connection.driver_class">org.h2.Driver</property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<property name="connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property>
<property name="connection.pool_size">20</property>

H2 Database

For those who are wondering how I got H2 running on a remote machine, the command line I used is: 

java -cp ./h2-1.2.136.jar org.h2.tools.Server -web -tcp -tcpAllowOthers -baseDir /var/spool/javadb/h2

Thus any database you create will be stored in this location, so with the above example I will have a database called /var/spool/javadb/h2/xwiki23.

Get Connected