Confluence won't start after collation change in SQL Server
Asked by Steve Rhodes:

I have a production database running on SQL Server 2012 Confluence 5.2.5. I want to upgrade this to 5.7.1 on the test environment but before that I need to change the database collation to CS_AS from CI_AS. I have done this with scripts generated by collation tool from Total Soft Services (<http://totalsoftservices.com/components/change-database-collation>) I have restored the production database to the test, changed the collation, changed the connection string in confluence.cfg.xml to point to the test, and restarted the app. However, i get a few errors in the atlassian-confluence.log. The main points seem to be:

```
2015-03-11 12:03:45,804 WARN [main] [atlassian.config.bootstrap.DefaultAtlassianBootstrapManager] getDatabaseBuildNumber Unable to determine build number from database. If you are upgrading from a Confluence version prior to 2.3, this is expected: Invalid object name 'CONFVERSION'.2015-03-11 12:03:45,913 ERROR [main] [sf.hibernate.util.JDBCExceptionReporter] logExceptions Invalid object name 'BANDANA'.2015-03-11 12:03:45,913 ERROR [main] [atlassian.confluence.plugin.PluginFrameworkContextListener] contextInitialized Error initialising plugin manager: Hibernate operation: Could not execute query; bad SQL grammar []; nested exception is java.sql.SQLException: Invalid object name 'BANDANA'.2015-03-11 12:03:45,944 ERROR [main] [sf.hibernate.util.JDBCExceptionReporter] logExceptions Invalid object name 'INDEXQUEUEENTRIES'.2015-03-11 12:03:45,960 ERROR [main] [atlassian.event.internal.AsynchronousAbleEventDispatcher] run There was an exception thrown trying to dispatch event 'com.atlassian.config.lifecycle.events.ApplicationStartedEvent@1e196a60' from the invoker 'SingleParameterMethodListenerInvoker{method=public void com.atlassian.confluence.search.lucene.queue.DatabaseIndexTaskQueue.flushIndexTaskQueue(com.atlassian.config.lifecycle.events.ApplicationStartedEvent),listener=com.atlassian.confluence.search.lucene.queue.DatabaseIndexTaskQueue@26f30784}'.java.lang.RuntimeException: Hibernate operation: Could not execute query; bad SQL grammar []; nested exception is java.sql.SQLException: Invalid object name 'INDEXQUEUEENTRIES'.
```

After which, Confluence stops, and the UI displays a 404. Can anyone help? The version has stayed the same. The things that have changed are the confluence.cfg.xml connection to the new db, and the collation (which is required for the upgrade past 5.5).


Answers:
author: Arya Banerjee
body: Hi Steve,

We also faced a similar situation while upgrading our Confluence instance from 5.4 to 5.6 few months back. unfortunately post 5.6 versions of COnfluence support only SQL Server databases having database collation as CS_AS.

The usual collation alter softwares work okay but may result into some other problems also which Atlassian might not support.

We had to take the back up of the data from the database, drop and recreate the database with new collation setting and then again run the Confluence installation afresh for the required version. For getting the previous stuffs, an XML import would suffice.

Regards,

Arya


author: Steve Rhodes
body: It appears that I was wrong about the problem being the collation change. The problem was the schema. In production, the schema was confluenceschema and working just fine. Despite what this KB article says: <https://confluence.atlassian.com/display/CONFKB/Confluence+Throws+an+%27Invalid+object+name+BANDANA%27+Error> about the user not being set up to use the default schema (which was confluenceschema and correctly set up to mirror the production setup), I changed the schema of the database to dbo, deleted the confluenceschema and recreated the user to make sure (with dbo as default schema). Script used to generate the schema commands below.

```
SELECT 'ALTER SCHEMA dbo TRANSFER ' + SysSchemas.Name + '.' + DbObjects.Name + ';' AS confluenceschemaFROM sys.objects DbObjectsINNER JOIN sys.schemas SysSchemas ON DbObjects.schema_id = SysSchemas.schema_idWHERE SysSchemas.Name = 'confluenceschema'AND (DbObjects.Type IN ('U', 'P', 'V'))ORDER BY confluenceschemaGO
```


Tags: bandana

collation

confluence-administration

ms-sql