Wiki source code of H2 Installation
Last modified by Vincent Massol on 2017/09/06
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
5.1 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
2 | {{toc/}} | ||
3 | {{/box}} | ||
![]() |
1.1 | 4 | |
![]() |
4.1 | 5 | [[H2>>http://h2database.com]] is a fast, free, in-memory or disk-based java database. |
![]() |
2.2 | 6 | |
![]() |
3.1 | 7 | Follow these instructions to use it with XWiki: |
![]() |
2.5 | 8 | |
![]() |
3.1 | 9 | * H2 is a very simple database to configure as you don't need to install nor to start it before being able to use it. It comes as a single JAR file named ##h2*.jar##. You'll need to [[download this JAR>>http://www.h2database.com/html/download.html]] and copy it in your ##WEB-INF/lib## directory. |
10 | * Once this is done, you need to configure XWiki to use H2 and to tell it where the database files will be created. To do this, edit the ##WEB-INF/hibernate.cfg.xml## file where you have expanded the XWiki WAR file and uncommented the H2 part. If you're using an old version of XWiki you won't find a commented out section for H2. In this case, use the following:((( | ||
11 | {{code language="xml"}} | ||
12 | <property name="connection.url">jdbc:h2:${environment.permanentDirectory}/database/xwiki</property> | ||
13 | <property name="connection.username">sa</property> | ||
14 | <property name="connection.password"></property> | ||
15 | <property name="connection.driver_class">org.h2.Driver</property> | ||
16 | <property name="dialect">org.hibernate.dialect.H2Dialect</property> | ||
17 | {{/code}} | ||
18 | ))) | ||
![]() |
1.1 | 19 | |
![]() |
4.1 | 20 | = Using a JDBC DataSource = |
![]() |
2.2 | 21 | |
![]() |
1.1 | 22 | {{code language="xml"}} |
![]() |
2.5 | 23 | <property name="connection.datasource">java:comp/env/jdbc/XWikiDS</property> |
24 | <property name="dialect">org.hibernate.dialect.H2Dialect</property> | ||
![]() |
1.1 | 25 | {{/code}} |
26 | |||
![]() |
4.1 | 27 | = Using a remote H2 instance = |
![]() |
1.1 | 28 | |
29 | {{code language="xml"}} | ||
![]() |
2.5 | 30 | <property name="connection.url">jdbc:h2:tcp://remotehost/xwiki23</property> |
![]() |
1.1 | 31 | {{/code}} |
![]() |
2.2 | 32 | |
![]() |
3.1 | 33 | On the H2 side, here's one way to have H2 running on a remote machine: |
![]() |
2.2 | 34 | |
35 | {{code language="bash"}} | ||
36 | java -cp ./h2-1.2.136.jar org.h2.tools.Server -web -tcp -tcpAllowOthers -baseDir /var/spool/javadb/h2 | ||
37 | {{/code}} | ||
38 | |||
![]() |
3.1 | 39 | Thus any database you create will be stored in this location, so with the above example you will have a database called ##/var/spool/javadb/h2/xwiki23##. |