Solve the problem of Chinese garbled openfire after using MySQL database

Source: Internet
Author: User

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&amp;characterencoding=utf8</ Serverurl>

Note: Because & has a special meaning, the original & symbol must be escaped as a &amp;

Solve the problem of Chinese garbled openfire after using MySQL database (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.