Configuring an Oracle Datasource in Apache Tomcat

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This page tells you how to set up an Oracle datasource connection for Confluence.

Step 1. Shut down Tomcat

  1. Run bin/shutdown.sh or bin/shutdown.bat to bring Tomcat down while you are making these changes.
  2. 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

  1. Download the Oracle JDBC driver. Links are available on this page: Database JDBC Drivers.
  2. Copy the driver JAR file into the lib folder of your Tomcat installation: <TOMCAT-INSTALLATION>/lib.

Step 3. Configure Tomcat

  1. 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.
  2. Find the Context element in the Host 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>
    
  3. Insert the DataSource Resource element into the Context element, directly after the opening <Context.../> line,  before Manager, 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>
    
  4. Change the username and password to match your Oracle login.
  5. 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
    
  6. If required, choose different maxTotal and maxIdle 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:

  1. Edit this file in your Confluence installation: <CONFLUENCE_INSTALLATION>/confluence/WEB-INF/web.xml.
  2. 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.

Last modified on Dec 2, 2015

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.