Configure Oracle Manually
Steps
To configure XWiki to store its data in an Oracle database, once you have installed and configured a servlet container with the XWiki WAR deployed:
- Install a supported Oracle Database version.
- Download the Oracle JDBC driver matching your Oracle version and the Java version XWiki runs on.
- Copy the JDBC driver JAR, for example ojdbc17.jar, into the XWiki web application's WEB-INF/lib directory, or into the servlet container's common library directory.
- Start Oracle and connect to it as a DBA or system user, for example with SQL*Plus.
sqlplus system/<password>@//localhost:1521/<service name> - Create the database user for the main wiki.
CREATE USER xwiki IDENTIFIED BY xwiki; - Grant the xwiki user the privileges it needs.
GRANT CREATE SESSION TO xwiki; GRANT RESOURCE TO xwiki; GRANT DBA TO xwiki; - (Optional) List the existing data files, to choose a path for a dedicated tablespace.
SELECT * FROM dba_data_files; - (Optional) Create a dedicated xwiki tablespace and make it the default for the xwiki user, instead of Oracle's default USERS tablespace.
CREATE TABLESPACE xwiki DATAFILE '/opt/oracle/oradata/<SID>/<PDB>/xwiki01.dbf' SIZE 1m AUTOEXTEND ON MAXSIZE 1g; ALTER USER xwiki DEFAULT TABLESPACE xwiki TEMPORARY TABLESPACE temp; - Give the xwiki user an unlimited quota on the tablespace it uses, since a new user gets none.
ALTER USER xwiki QUOTA UNLIMITED ON users;Replace users with xwiki if you created a dedicated tablespace in the previous step.
- Comment out the configuration section of the database currently active in the WEB-INF/hibernate.cfg.xml file of the expanded XWiki WAR.
- Uncomment the "Oracle configuration" section of the same file, in full, including the mapping entries at its end.
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property> <property name="hibernate.connection.username">xwiki</property> <property name="hibernate.connection.password">xwiki</property> <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.SetBigStringTryClob">true</property> <property name="hibernate.jdbc.batch_size">0</property> <property name="hibernate.jdbc.use_streams_for_binary">false</property> <property name="hibernate.dbcp.poolPreparedStatements">true</property> <property name="hibernate.dbcp.maxOpenPreparedStatements">20</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.oracle.hbm.xml"/> <mapping resource="feeds.oracle.hbm.xml"/> <mapping resource="mailsender.oracle.hbm.xml"/> - Review the hibernate.connection.url property, and the user name and password, against the database you created.
- Start XWiki.
- Open your wiki in a browser. XWiki connects to Oracle, creates its tables on first start, and serves the wiki without a database error.
FAQ
Which Oracle JDBC driver should I use?
Use the driver matching the Java version XWiki runs on, not the one matching your Oracle release. XWiki's own build and functional tests use ojdbc17, published on Maven Central as com.oracle.database.jdbc:ojdbc17; picking the wrong JAR causes startup and save errors.
How do I find the service name or the SID for the connection property?
Both are listed in the tnsnames.ora file of the Oracle installation's network/admin directory. XE is the default SID of an Oracle Express installation. Write @host:port:SID for a SID, and @host:port/service for a service name.
Do I need to enlarge the default USERS tablespace?
For anything beyond a trial, yes. Resize its data file, with ALTER DATABASE DATAFILE '/opt/oracle/oradata/<SID>/<PDB>/users01.dbf' RESIZE 100M;.
Must the xwiki user have the DBA role?
The steps above grant it for simplicity. For a restricted set of privileges, see the "Permissions" section of the Oracle Installation page.
How do I remove the XWiki database?
Run DROP USER xwiki CASCADE;, and DROP TABLESPACE xwiki INCLUDING CONTENTS AND DATAFILES; if you created a dedicated tablespace. Every subwiki is a separate Oracle user, so drop those users too.
More
To find more about the current topic, you can search or use the table below and filter the columns to narrow your choices.
Related
- Configure Oracle for XWiki in Docker.
- Configure Oracle in a Virtual Machine.
- Oracle Installation, for multi-wiki support, indexes, permissions and Oracle Wallet.