How to convert a datasource to a direct JDBC connection
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.
These steps will take you through performing this process in a test system first, to ensure the process works smoothly, before applying to production.
- 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'.
- Backup your test system's install folder, home folder, and database.
- 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'.
- Create a new empty database in your database system
- Install a new Confluence instance and set it up, pointing to the new, empty database
- 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.
- 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 etc.
- Replace these values in the new file with the values from the test system:
- Database username
- Database user password
- 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.
- Shut down your test system
- Rename the test system's confluence.cfg.xml to a filename that will not be picked up
- Place the new system's confluence.cfg.xml in the home directory of the test system
- Start Confluence up again
- If everything works in the live test system, you can apply this change to production:
- Shut down production
- Backup your production Confluence install folder, home folder, and database
- 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.
- Copy the file into the home directory of production
- Restart production
- Remove the new system as it's no longer required.