Configure H2
Steps
To configure XWiki to use H2, which runs inside the same JVM as XWiki and needs no database server to install or start:
- Make sure you have already installed and configured a servlet container for XWiki (e.g. Tomcat or Jetty), with the XWiki WAR file extracted/deployed.
- Download H2 from the H2 website or from the Maven Central repository. It is a single jar file.
- Copy that jar into the WEB-INF/lib directory of the expanded XWiki WAR. XWiki ships no H2 driver.
$ cp h2-*.jar /path/to/webapps/xwiki/WEB-INF/lib/ - Edit the WEB-INF/hibernate.cfg.xml file, comment out the database block that is currently active and uncomment the H2 one. The shipped connection URL puts the database file in XWiki's permanent directory and needs no editing unless you want it somewhere else.
<property name="hibernate.connection.url">jdbc:h2:${environment.permanentDirectory}/database/xwiki</property> <property name="hibernate.connection.username">sa</property> <property name="hibernate.connection.password"></property> <property name="hibernate.connection.driver_class">org.h2.Driver</property> <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property> <property name="hibernate.connection.charSet">UTF-8</property> <property name="hibernate.connection.useUnicode">true</property> <property name="hibernate.connection.characterEncoding">utf8</property> <mapping resource="xwiki.hbm.xml"/> <mapping resource="feeds.hbm.xml"/> <mapping resource="instance.hbm.xml"/> <mapping resource="notification-filter-preferences.hbm.xml"/> - Add the mail sender mapping to that list, which the shipped H2 block is missing.
<mapping resource="mailsender.hbm.xml"/> - Start or restart the application server. XWiki creates the database and its tables on the first run.
- Verify that the directory in the connection URL now holds the database file.
$ ls /path/to/permanent/directory/database xwiki.mv.db
FAQ
Do I have to set a username and a password?
No, and the shipped block relies on that: a new H2 database has the user sa and no password. Set a real one, in the database and in hibernate.connection.password, before anything but XWiki can reach it.
Can the main wiki use a schema other than PUBLIC?
Yes. PUBLIC is H2's default schema; set the xwiki.db property in xwiki.cfg to the schema you want instead.
Why does the shipped H2 block need the mail sender mapping added by hand?
Because of a packaging defect (XWIKI-25585): the H2 and Derby blocks are the only two of the eight in hibernate.cfg.xml generated without mailsender.hbm.xml, which XWiki needs in order to store the statuses of the mails it sends.
More
To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.