Configuring an Oracle Datasource in Apache Tomcat
This page tells you how to set up an Oracle datasource connection for Confluence.
Step 1. Shut down Tomcat
- Run
bin/shutdown.sh
orbin/shutdown.bat
to bring Tomcat down while you are making these changes. - Make a backup of your
<CONFLUENCE_HOME>/confluence.cfg.xml
file and your<CONFLUENCE_INSTALLATION>/conf/server.xml
file, so that you can easily revert if you have a problem.
Step 2. Install the Oracle database driver
- Download the Oracle JDBC driver. Links are available on this page: Database JDBC Drivers.
- Copy the driver JAR file into the
lib
folder of your Tomcat installation:<TOMCAT-INSTALLATION>/lib
.
Step 3. Configure Tomcat
- If you are using the Confluence distribution, edit the
conf/server.xml
file in your Tomcat installation. If you are running your own Tomcat instance, edit the XML file where you declared the Confluence Context descriptor. Find the
Context
element in theHost
element:
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false"> <Context path="" docBase="../confluence" debug="0" reloadable="true"> <!-- Logger is deprecated in Tomcat 5.5. Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties --> <Manager pathname="" /> </Context> </Host>
Insert the DataSource
Resource
element into theContext
element, directly after the opening<Context.../>
line, beforeManager,
as shown here:<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false"> <Context path="" docBase="../confluence" debug="0" reloadable="true"> <!-- Logger is deprecated in Tomcat 5.5. Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties --> <!-- If you're using Confluence 5.7 or below; change maxTotal to maxActive --> <Resource name="jdbc/confluence" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@hostname:port:sid" username="<username>" password="<password>" connectionProperties="SetBigStringTryClob=true" accessToUnderlyingConnectionAllowed="true" maxTotal="25" maxIdle="10" maxWaitMillis="10000" /> <Manager pathname="" /> </Context> </Host>
- Change the
username
andpassword
to match your Oracle login. Change the
url
to match the URL for your Oracle database. See how to find your Oracle URL. For example:jdbc:oracle:thin:@example.atlassian.com:1521:confluencedb
- If required, choose different
maxTotal
andmaxIdle
values. These define the number of database connections that will be allowed at one time, and the number that will be kept open even when there is no database activity.
Step 4. Configure the Confluence web application
Configure Confluence to use this datasource:
- Edit this file in your Confluence installation:
<CONFLUENCE_INSTALLATION>/
confluence/WEB-INF/web.xml Insert the following element just before
</web-app>
near the end of the file:<resource-ref> <description>Connection Pool</description> <res-ref-name>jdbc/confluence</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
Step 5. Restart Tomcat
Run bin/startup.sh
or bin/startup.bat
to start Tomcat with the new settings.