Last modified by superadmin on 2026/11/25 21:31

Show last authors
1 {{warning}}
2 H2 is not one of the [[databases XWiki supports>>dev:Community.SupportStrategy.DatabaseSupportStrategy]], and serving it over TCP adds a second risk: H2's own [[documentation>>https://www.h2database.com/html/advanced.html]] says to pair ##-tcpAllowOthers##, the flag that opens the server to other machines, with a firewall and a strong password. Keep the port reachable only from the XWiki machine.
3 {{/warning}}
4
5 1. Set XWiki up for H2 as described in [[Configure H2>>doc:documentation.xs.admin.installation.install-relational-database.configure-h2.WebHome]] first. The H2 jar goes into ##WEB-INF/lib## on the XWiki machine either way.
6 1. On the database machine, download the same H2 version and create the database **locally**, in the directory you will serve from. H2 refuses to create a database over a remote connection.(((
7 {{code language="none"}}
8 $ java -cp h2-*.jar org.h2.tools.Shell -url jdbc:h2:/var/spool/javadb/h2/xwiki -user sa
9 {{/code}}
10 )))
11 1. Start the H2 server there, pointing ##-baseDir## at the directory holding that database.(((
12 {{code language="none"}}
13 $ java -cp h2-*.jar org.h2.tools.Server -tcp -tcpAllowOthers -baseDir /var/spool/javadb/h2
14 {{/code}}
15 )))
16 1. On the XWiki machine, point ##hibernate.connection.url## at the server instead of at a local path. The database name is resolved against the server's ##-baseDir##, so this URL opens the database you created above.(((
17 {{code language="xml"}}
18 <property name="hibernate.connection.url">jdbc:h2:tcp://remotehost/xwiki</property>
19 {{/code}}
20 )))
21 1. Restart the application server.
22 1. Verify that XWiki serves its pages, and that the database file on the server has grown past the empty database you created.(((
23 {{code language="none"}}
24 $ ls -l /var/spool/javadb/h2
25 -rw-r--r-- 1 h2 h2 23068672 Oct 23 18:02 xwiki.mv.db
26 {{/code}}
27 )))

Get Connected