The problem of Chinese garbled characters appearing when connecting to MySQL database in Idea

The problem of Chinese garbled characters appearing when connecting to MySQL database in Idea

Problem: When using JDBC to connect to the MySQL database, garbled characters are displayed when inserting Chinese characters Solution: Insert the following code into the connection code

String url = "jdbc:mysql://localhost:3306/your database name?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false";

Code Interpretation

useUnicode=true&characterEncoding=utf8

The above code has two effects:
1. When storing data:
When storing project data, the database will first decode the data into bytecode using the UTF-8 format, and then store the decoded bytecode back into the database using the GBK encoding.

2. When fetching data:
When retrieving data from the database, the database will first decode the data in the database into bytecode in GBK format, then re-encode the decoded bytecode in UTF-8 format, and finally return the data to the client.

serverTimezone=UTC

The above code is to specify the time zone. After adding this code, the time zone error will not be reported.

useSSL=false

For higher versions of MySQL, you need to specify whether to use an SSL connection.

This is the end of this article about the problem of garbled Chinese characters when Idea connects to MySQL database. For more related content about garbled Chinese characters when Idea connects to MySQL database, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solve the problem that the Terminal in idea cannot execute GIT commands + Terminal Chinese garbled characters
  • IntelliJ Idea 2020.1 is officially released, officially supports Chinese (must read)
  • Solve the problem of IntelliJ IDEA console outputting garbled Chinese characters (the simplest one in history)
  • Detailed explanation of the solution to the problem of garbled Chinese characters in the .properties file in Intellij IDEA
  • IntelliJ IDEA is now available in Chinese

<<:  Chinese website user experience rankings

>>:  How to use CSS styles and selectors

Recommend

Nginx anti-crawler strategy to prevent UA from crawling websites

Added anti-crawler policy file: vim /usr/www/serv...

Example of horizontal arrangement of li tags in HTMl

Most navigation bars are arranged horizontally as...

Detailed explanation of HTML's <input> tag and how to disable it

Definition and Usage The <input> tag is use...

Implementation steps for setting up the React+Ant Design development environment

Basics 1. Use scaffolding to create a project and...

Vue+element ui realizes anchor positioning

This article example shares the specific code of ...

How to use React to implement image recognition app

Let me show you the effect picture first. Persona...

Nginx reverse proxy to go-fastdfs case explanation

background go-fastdfs is a distributed file syste...

The basic use of html includes links, style sheets, span and div, etc.

1. Links Hypertext links are very important in HTM...

How to verify whether MySQL is installed successfully

After MySQL is installed, you can verify whether ...

Example of how to deploy Spring Boot using Docker

Here we mainly use spring-boot out of the box, wh...

CentOS 6.4 MySQL 5.7.18 installation and configuration method graphic tutorial

The specific steps of installing mysql5.7.18 unde...

Detailed explanation of MySQL trigger trigger example

Table of contents What is a trigger Create a trig...

Learn MySQL database in one hour (Zhang Guo)

Table of contents 1. Database Overview 1.1 Develo...

CSS container background 10 color gradient Demo (linear-gradient())

grammar background: linear-gradient(direction,col...