OpenFire is a very good IM server, and is a pure Java implementation, with multiple platform version, his data storage can use a variety of databases, such as Mysql,oracle.
In the actual use of the most encountered is the use of MySQL database after the Chinese garbled problem, the problem is very interesting, and from the phenomenon can be seen in openfire internal mechanisms.
The real problem is this: start the OpenFire server first, then use the client or login directly to the background to create a new account, specify some Chinese properties for the account, such as name. If you do not restart the server, you will never feel that there is something wrong, because all the Chinese display is normal. Then restart the OpenFire, and then use the established account to log in to the client or into the background management side to view, will find all the Chinese has become a question mark. Log in to the database and see that all Chinese characters are also question marks, indicating two questions:
OpenFire has an application-level cache
There is a problem with database encoding
The solution is also very simple, first of all to ensure that you create for OpenFire database encoding is UTF8, the table statement is as follows:
Create DATABASE openfire default character set UTF8 default collate utf8_general_ci
When you create a database, you can use:
ALTER DATABASE openfire default character set UTF8 default collate utf8_general_ci;
Secondly, in initializing the OpenFire database, that is, when the OpenFire server is configured for the first time, the connection string in the connection database is added to the character encoding format, the encoding requirements for the UTF8 must be added to the connection, and the connection strings are set as follows:
Jdbc:mysql://127.0.0.1:3306/openfire?useunicode=true&characterencoding=utf8
If the installation is complete, this configuration can be changed, go directly to the OpenFire installation directory, find conf/openfire.xml such a file, open to find the following XML section, modify the ServerURL can be
<database>
<defaultProvider>
<driver>com.mysql.jdbc.Driver</driver>
<serverurl>jdbc:mysql://127.0.0.1:3306/openfire?useunicode=true&characterencoding=utf8</ Serverurl>
Note: Because & has a special meaning, the original & symbol must be escaped as a &
Solve the problem of Chinese garbled openfire after using MySQL database (GO)