How to convert a datasource to a direct JDBC connection

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

If you currently connect to your Confluence database via a datasource configured in your server.xml  and you want to use a direct JDBC connection configured in confluence.cfg.xml  instead, this document will help you do that.

Solution

These steps will take you through performing this process in a test system first, to ensure the process works smoothly, before applying to production.

  1. Create a test Confluence server if you don't already have one. For the rest of these steps we will call this the 'test system'.
  2. Backup your test system's install folder, home folder, and database.
  3. Generate a new confluence.cfg.xml  with all the parameters filled out automatically, by installing a new version of Confluence. For the rest of these steps we will call this the 'new system'.
    1. Create a new empty database in your database system
    2. Install a new Confluence instance and set it up, pointing to the new, empty database
      1. If at this point you receive a warning about overwriting content in the database, do not proceed. This means you are accidentally pointing to your production or test database, or a database that has Confluence data in it already. Check your configuration of the new system, especially <confluence-install>/confluence/WEB-INF/classes/confluence-init.properties , and start again.
    3. Once the new system has started, take the confluence.cfg.xml  file and compare it to your current one. Make a note of any differing values, eg c3p0.maxSize , hikari etc.
  4. Replace these values in the new file with the values from the test system:
    1. Database name
    2. Database username
    3. Database user password
  5. Make any changes to the parameters of the new config file that you noted in step 2-c above. At this stage the new system's confluence.cfg.xml has all the parameters to connect to the test system's database via Direct JDBC.
  6. Shut down your test system
  7. Rename the test system's confluence.cfg.xml  to a filename that will not be picked up
  8. Place the new system's confluence.cfg.xml  in the home directory of the test system
  9. Start Confluence up again
  10. If everything works in the live test system, you can apply this change to production:
    1. Shut down production
    2. Backup your production Confluence install folder, home folder, and database
    3. Modify the database connection information in the new confluence.cfg.xml  to the values of the production database. At this stage the new confluence.cfg.xml  has all the parameters to connect to the production system's database via Direct JDBC.
    4. Copy the file into the home directory of production
    5. Restart production
  11. Remove the new system as it's no longer required.

MigrateDatasourceToDirectJDBC



Last modified on Apr 4, 2024

Was this helpful?

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