Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Download the MySQL Connector/J JDBC driver from http://dev.mysql.com/downloads/connector/j/
  2. After unpacking the file you have downloaded, you will find a file called something like mysql-connector-java-5.1.18-bin.jar.
  3. If you are running Tomcat 7 or Tomcat 6, copy the file into <tomcat-install>/lib. On Tomcat 5.5, copy this file into the common/lib directory of your Tomcat installation. For Tomcat 6, copy the file into <tomcat-install>/lib.

3. Configure Tomcat

  1. If you are using the Confluence distribution, edit the

    Edit <tomcat-install>/conf/

    server

    context.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.

    If editing Tomcat 5.5 you edit <tomcat-install>/conf/server.xml, find the following lines:

     

    <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 -->

    .

     

  2. Within the Context tags, directly after the opening <Context.../> line, insert the DataSource Resourcetag:

     

    <Resource name="jdbc/
    confluence
    TermWebDS"
                auth="Container"
                type="javax.sql.DataSource"
             
                username="
    yourusername
    termwebuser"
             
                password="
    yourpassword
    termwebpassword"
             
                driverClassName="com.mysql.jdbc.Driver"
             
                url="jdbc:mysql://localhost:3306/
    confluence?
    termweb?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf8"
             
                maxActive="
    15
    20"
             
                maxIdle="
    7
    10"
             defaultTransactionIsolation="READ_COMMITTED"
             validationQuery="Select
                validationQuery="Select 1"/>

     

    • Replace the username and password parameters with the correct values for your database.
    • In the url parameter, replace the word 'confluencetermweb' with the name of the database your Confluence TermWeb data will be stored in.
    • If you plan to use non-Latin characters, you will also need to add "&useUnicode=true&characterEncoding=utf8" on the end of the above URL. These options are not required for any database other than MySQL.
Notes

...

  • Why is the validationQuery element needed? When a database server reboots, or there is a network failure, all the connections in the connection pool are broken and this normally requires an application server reboot.

    However, the Commons DBCP (Database Connection Pool) which is used by the Tomcat application server can validate connections before issuing them by running a simple SQL query, and if a broken connection is detected, a new one is created to replace it. To do this, you will need to set the "validationQuery" option on the database connection pool.
  • The configuration properties for Tomcat's standard data source resource factory (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory) are as follows:
    • driverClassName – Fully qualified Java class name of the JDBC driver to be used.
    • maxActive – The maximum number of active instances that can be allocated from this pool at the same time.
    • maxIdle – The maximum number of connections that can sit idle in this pool at the same time.
    • maxWait – The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.
    • password – Database password to be passed to our JDBC driver.
    • url – Connection URL to be passed to our JDBC driver. (For backwards compatibility, the property driverName is also recognized.)
    • user – Database username to be passed to our JDBC driver.
    • validationQuery – SQL query that can be used by the pool to validate connections before they are returned to the application. If specified, this query MUST be an SQL SELECT statement that returns at least one row.

4. Configure the

...

TermWeb Web Application

Info

This step is only necessary if you for some reason need to use another data source name than the default TermWebDS. In this case you will have to reapply these changes after every upgrade or reinstall of TermWeb.

  1. Edit <tomcat-install>/webapps/termweb/WEB-INF/web.xml in your Confluence installation.
  2. Go to the end of the file and insert locate the following element just before </web-app>:

     

    <resource-ref>
            <description>Connection Pool</description>
            
    ...
        <res-ref-name>jdbc/
    confluence<
    TermWebDS</res-ref-name>
            <res-type>javax
    ..
    sql
    .
    DataSource</res-type>

            <res-auth>Container</res-auth>
        
    </resource-ref>

5. Configure Confluence

If you have not yet set up Confluence:

  1. Follow the steps in the Confluence Setup Guide
  2. In the Database Setup section, choose the "Datasource Connection" option.
  3. Set the JNDI name to java:comp/env/jdbc/confluence
  4. Set the Database dialect to MySQL.

If you are changing an existing Confluence installation over to using a Tomcat datasource:

  1. Find your ConfluenceHome directory (see: Confluence Home Directory if you don't know where it is).
  2. Edit the confluence.cfg.xml file
  3. Delete any line that contains a property that begins with hibernate.
  4. Insert the following at the start of the <properties>section.

     

    <property name="hibernate.setup"><![CDATA[true]]></property>
        <property name="hibernate.dialect"><![CDATA[net.sf.hibernate.dialect.MySQLDialect]]></property>
        <property name="hibernate.connection.datasource"><![CDATA[java:comp/env/jdbc/confluence]]></property>

...

  1.  

  2. Change jdbc/TermWebDS to your desired JNDI data source name.
  3. Use the same data source name in the file you edited in the previous step

5. Restart Tomcat

Run bin/startup.sh or bin/startup.bat to start Tomcat and TermWeb with the new settings.