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

Recommend some useful learning materials for newbies in web design

Many people also asked me what books I read when ...

MySQL 5.7.21 winx64 installation and configuration method graphic tutorial

This article summarizes the notes for installing ...

Pure CSS and Flutter realize breathing light effect respectively (example code)

Last time, a very studious fan asked if it was po...

Detailed explanation of Vue life cycle

Table of contents Why understand the life cycle W...

WeChat applet development chapter: pitfall record

Recently, I participated in the development of th...

jQuery implements Table paging effect

This article shares the specific code of jQuery t...

Stealing data using CSS in Firefox

0x00 Introduction A few months ago, I found a vul...

Analysis of the principle of Mybatis mapper dynamic proxy

Preface Before we start explaining the principle ...

Detailed installation and configuration of MySql on Mac

1. Download and install Download the community ed...

Sqoop export map100% reduce0% stuck in various reasons and solutions

I call this kind of bug a typical "Hamlet&qu...

MySql inserts data successfully but reports [Err] 1055 error solution

1. Question: I have been doing insert operations ...

JavaScript implements click toggle function

This article example shares the specific code of ...

A mobile adaptive web page effect solves the problem of small display page

For work needs, I need to make a mobile phone adap...