Configuring a MySQL Datasource in Apache Tomcat

Confluence is very helpful to share work with your team members, if and when you have to. It’s a centralized place where you can work together on projects

This articles help you to set up a MySQL datasource connection for Confluence.

logoConfluencePNG(1)

Step 1: Shut down Tomcat

Run following command to bring Tomcat down while you are making these changes.

# cd <CONFLUENCE_INSTALLATION>/bin
# ./shutdown.sh

Step 2: MySQL database driver

You need to make the MySQL JDBC driver available to your application server, as described in the appropriate setup guide.

Step 3: Configure Tomcat

Edit server.xml file in your Tomcat installation.

# vim <CONFLUENCE_INSTALLATION>/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 -->

Insert the DataSource Resource element within the Context element.

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

Description:
username: Database username to be gone to your JDBC driver.
password: Database password to be gone to your JDBC driver.
driverClassName: Completely qualified Java class name of the JDBC driver to be utilized.
url: Connection URL to be gone to your JDBC driver.
maxActive: The greatest number of active instances that can be allocated from this pool in the meantime.
maxIdle: The greatest number of connections that can sit in this pool in the meantime.
validationQuery: SQL inquiry that can be utilized by the pool to approve connections before they are come back to the application.

Step 4: Configure the Confluence web application

Edit server.xml file in your Confluence installation.

# vim <CONFLUENCE_INSTALLATION>/confluence/WEB-INF/web.xml

Embed the following component just before </web-app> close to 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: Start Tomcat

Run following command to bring Tomcat up while you are making these changes.

# cd <CONFLUENCE_INSTALLATION>/bin
# ./startup.sh

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.