Last modified by Eleni Cojocariu on 2026/11/25 14:41

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 To run H2 on a separate machine and have XWiki reach it over TCP, instead of the embedded database [[Configure H2>>doc:documentation.xs.admin.installation.database.configure-h2.WebHome]] sets up:
6
7 1. Set XWiki up for H2 as described there first. The H2 jar goes into ##WEB-INF/lib## on the XWiki machine either way.
8 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.(((
9 {{code language="none"}}
10 $ java -cp h2-*.jar org.h2.tools.Shell -url jdbc:h2:/var/spool/javadb/h2/xwiki -user sa
11 {{/code}}
12 )))
13 1. Start the H2 server there, pointing ##-baseDir## at the directory holding that database.(((
14 {{code language="none"}}
15 $ java -cp h2-*.jar org.h2.tools.Server -tcp -tcpAllowOthers -baseDir /var/spool/javadb/h2
16 {{/code}}
17 )))
18 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.(((
19 {{code language="xml"}}
20 <property name="hibernate.connection.url">jdbc:h2:tcp://remotehost/xwiki</property>
21 {{/code}}
22 )))
23 1. Restart the application server.
24 1. Verify that XWiki serves its pages, and that the database file on the server has grown past the empty database you created.(((
25 {{code language="none"}}
26 $ ls -l /var/spool/javadb/h2
27 -rw-r--r-- 1 h2 h2 23068672 Oct 23 18:02 xwiki.mv.db
28 {{/code}}
29 )))

Get Connected