当前位置:网站首页>Openfire solves the problem of Chinese garbled code after using MySQL database
Openfire solves the problem of Chinese garbled code after using MySQL database
2022-06-30 20:13:00 【Brother Xing plays with the clouds】
Openfire It's a very good one IM The server , And it's pure Java Realization , Versions with multiple platforms , His data can be stored in a variety of databases , Such as MySQL,Oracle etc. .
In actual use, the most common thing we encounter is to use MySQL Chinese garbled code behind the database , This question is very interesting , And it can be seen from the phenomenon Openfire Some internal mechanisms .
The practical problem is : First start Openfire The server , Then create a new account by using the client or directly logging in to the background , Specify some Chinese attributes for this account , Such as name, etc . If you don't restart The server , You will never feel anything wrong , Because all Chinese displays are normal . Next, restart it Openfire, Use the established account to log in to the client or enter the background management side to view , You will find that all Chinese has become a question mark . Log in to the database to view , It is found that all Chinese characters are also question marks , This illustrates two problems :
- Openfire With application layer cache
- There is a problem with the database encoding
The solution is very simple , First make sure you are openfire The database code created is utf8 Of , Build the predicative sentence as follows :
create database openfire default character set utf8 default collate utf8_general_ci
When you have already created the database , You can use it. :
alter database openfire default character set utf8 default collate utf8_general_ci;
secondly , Initializing Openfire database , That is, the first configuration Openfire The server when , The character encoding format should be added to the connection string in the connection database , Must be added to the connection UTF8 Coding requirements for , The connection string settings are as follows :
jdbc:mysql://127.0.0.1:3306/openfire?useUnicode=true&characterEncoding=utf8
If the installation is complete , This configuration can also be changed , Direct to Openfire Installation directory , find conf/openfire.xml Such a document , Open and find the following XML section , Modify the serverURL that will do
<database>
<defaultProvider>
<driver>com.mysql.jdbc.Driver</driver>
<serverURL>jdbc:mysql://127.0.0.1:3306/openfire?useUnicode=true&characterEncoding=utf8</serverURL>
Be careful : because & Has a special meaning , Therefore, the original & The symbol must be escaped as &
边栏推荐
- Pytorch implements the calculation of flops and params
- Spark - 一文搞懂 Partitioner
- CADD course learning (1) -- basic knowledge of drug design
- 25:第三章:开发通行证服务:8:【注册/登录】接口:接收并校验“手机号和验证码”参数;(重点需要知道【利用redis来暂存数据,获取数据的】的应用场景)(使用到了【@Valid注解】参数校验)
- How to pass the PMP Exam quickly?
- Detailed steps for Django to upload excel tables and write data to the database
- Why must a digital transformation strategy include continuous testing?
- DELL R720服务器安装网卡Broadcom 5720驱动
- Exness: liquidity series - liquidity cleaning and reversal, decision interval
- TorchDrug--药物属性预测
猜你喜欢

The prospectus of pelt medical was "invalid" for the second time in the Hong Kong stock exchange, and the listing plan was substantially delayed
Source code analysis of redis ziplist compressed list

Idle fish is hard to turn over

杰理之触摸按键识别流程【篇】

如何快速通过PMP考试?

Transport layer uses sliding window to realize flow control
Application of JDBC in performance test

Enterprise middle office planning and it architecture microservice transformation
![25: Chapter 3: developing pass service: 8: [registration / login] interface: receiving and verifying](/img/ff/727c4a20ff3816ec7221dced5a4770.png)
25: Chapter 3: developing pass service: 8: [registration / login] interface: receiving and verifying "mobile number and verification code" parameters; (it is important to know the application scenario

漏洞扫描工具大全,妈妈再也不用担心我挖不到漏洞了
随机推荐
Taihu Lake "China's healthy agricultural products · mobile phone live broadcast" enters Taihu Lake
Conditional compilation
composer
Kubevela 1.4: make application delivery safer, easier to use, and more transparent
启动PHP报错ERROR: [pool www] cannot get uid for user ‘@[email protected]’
Web主机iptables防火墙安全脚本
凌云出海记 | 一零跃动&华为云:共助非洲普惠金融服务
GeoServer安装
Basic syntax of VB
Network planning | [five transport layers and six application layers] knowledge points and examples
Summary of operating system interview questions (updated from time to time)
Halcon知识:盘点一下计量对象【1】
屏幕显示技术进化史
C language: hashtable
This morning, investors began to travel collectively
How to pass the PMP Exam quickly?
QQmlApplicationEngine failed to load component qrc:/main.qml:-1 No such file or directory
小学期,第三场-下午:WEB_sessionlfi
Application of JDBC in performance test
以全栈全功能解决方案,应对多样工具复杂环境DevOps落地难题