Unicode Characters Not Supported By Default

Problem
Non-ASCII characters will not be displayed by Confluence.

Reason
The default SQL Server dialect uses column types that do not support Unicode, specifically the char, varchar and text column types. See CONF-4786 for details.

Solution
To add Unicode support, use the Unicode SQL Server dialect which uses nchar, nvarchar and ntext column types. Unicode SQL Server dialect has the downside of halving the maximum length of each column from 8000 characters to 4000, as every char is stored in two bytes.

Enable Unicode SQL Server dialect on a new setup, perform these steps prior to 'Stage 3 - Database Connection Setup' of the Database Setup For Any External Database:

  1. Open the mssql.properties file within your Confluence installation folder. In version 2.6, this file is located in the /confluence/WEB-INF/lib/confluence.2.6.0.jar file. jar files are similar to zip formats.
  2. Comment the line: dialect=net.sf.hibernate.dialect.SQLServerDialect
  3. Uncomment the line: #dialect=net.sf.hibernate.dialect.SQLServerIntlDialect
  4. Start the Confluence Setup Wizard

For existing SQL Server instances wishing to enable Unicode support:

  1. From Confluence, create an XML site backup
  2. From your DBA tool, create a full backup of the Confluence schema contents
  3. Confluence を停止します。
  4. Move your home directory
  5. Drop all tables from the Confluence schema
  6. Change the dialect to Unicode using the above instructions
  7. Follow the 'Stage 3 - Database Connection Setup' of Database Setup For Any External Database to setup the connection again and import the XML backup
  8. Once the Setup Wizard is complete, stop Confluence
  9. Copy any customised content and plugins from your old home directory into the new home directory
  10. Confluence を起動します。

This will not restore previously stored Unicode characters.

Use jTDS Driver 1.0.3 Or Later For JDBC Connection - Reason 1

Problem
When using jTDS driver 1.0.2 or earlier, Confluence may freeze when performing certain functions, and you see a warning like the one displayed below:

\[ERROR\] ActionSupport - \-An error occured while storing the requested page\! <org.springframework.jdbc.UncategorizedSQLException: (Hibernate operation): encountered SQLException
\[The amount of data read from the stream is not = length.\]; nested exception is java.sql.SQLException: The amount of data read from the stream is not = length.>

This can occur with jTDS driver 1.0.2 but is fixed in 1.0.3 - see the jTDS homepage . It will prevent backups from suceeding and lock access to the database when viewing certain pages.

Solution
Upgrade to jTDS driver 1.0.3 or later from the jTDS download page.

Use jTDS Driver 1.0.3 Or Later For JDBC Connection - Reason 2

Problem
When using MS SQL Server without the jTDS drivers, you may receive an error similar to:

net.sf.hibernate.LazyInitializationException: Exception initializing proxy: \[com.atlassian.confluence.spaces.SpaceDescription#5\]
 at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:64)
 at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164)
...
Caused by: java.sql.SQLException: \[Microsoft\]\[SQLServer 2000 Driver for JDBC\]ResultSet can not re-read row data for column 2.
 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
 at com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown Source)
 at com.microsoft.jdbc.base.BaseResultSet.getLong(Unknown Source)
 at com.microsoft.jdbc.base.BaseResultSet.getLong(Unknown Source)
 at org.jboss.resource.adapter.jdbc.WrappedResultSet.getLong(WrappedResultSet.java:338)
 at net.sf.hibernate.type.LongType.get(LongType.java:18)
 at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
 at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
 at net.sf.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:61)
 at net.sf.hibernate.loader.Loader.hydrate(Loader.java:686)
 at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:627)
 at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:586)
 at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
 at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
 at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
 at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
 at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
 at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
 at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
 at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
 at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)

We use a component in Confluence called Hibernate. According to Hibernate Documentation there may be issues with the Microsoft JDBC drivers resulting in the error you are seeing.

Solution
Upgrade to jTDS driver 1.0.3 or later from the jTDS download page. You may also consider alternative SQL Server drivers listed on the Hibernate page.

データベース文字エンコード設定

When creating the database schema, the database character encoding must be compatible with the application and Confluence character encoding as described in Configuring Database Character Encoding. If setting MS SQL to use UTF-8 is not an option, you can create a schema that uses UCS-2 encoding, and have the application and Confluence use UTF-8 encoding.

Setting up Authentication Mode of the SQL Server

During a login process to SQL server or while setting up your DB connection through the Setup Wizard, the following error may appear:

Login failed for user 'username'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452).

The cause of this error is that the SQL server has been configured to operate in 'Windows Authentication Mode (Windows Authentication)' and doesn't allow
the use of SQL accounts.

In order to resolve this problem, change the Authentication Mode of the SQL server from 'Windows Authentication Mode (Windows Authentication)'
to 'Mixed Mode (Windows Authentication and SQL Server Authentication)'.

Please refer to this Microsoft document for more details.