Home > Back-end >  Consult the Java connection mysql connection string in the characterEncoding=utf-8 is what mean? tha
Consult the Java connection mysql connection string in the characterEncoding=utf-8 is what mean? tha

Time:05-14

As follows: the utf-8 and GBK table said what? Read out data of the table in accordance with the GBK code? Or is it in accordance with the utf-8 read it out?
DBURL="JDBC: mysql://localhost: 3306/" + dbname + "? UseSSL=false& ServerTimezone=Asia/Shanghai& CharacterEncoding=utf-8 ";
DBURL="JDBC: mysql://localhost: 3306/" + dbname + "? UseSSL=false& ServerTimezone=Asia/Shanghai& GBK characterEncoding=";

CodePudding user response:

CharacterEncoding=role is to specify the processing characters of decoding and encoding format, or standard,

CodePudding user response:

As the upstairs said, if you specify different server code and, when the server will read and return, automatic to do encoding conversion,
Again, you read from the local data, such as is GBK, if encoding and you specified is not the same, specifies the UTF8, for example, you have nothing to take the initiative to transfer from GBK code UTF8, it will cause the database data processing error,

CodePudding user response:

1/f, reference the Java stack all route reply:
characterEncoding=role is to specify the processing characters of decoding and encoding format, or standard,

Thank you, what you mean?
First save my database list of characters, is utf-8, also may be GBK code
I want to achieve, the database either utf-8 or GBK, saved to a String or HASMAP are unified into utf-8
Consult how to do?
Thank you

CodePudding user response:

reference oracleperl reply: 3/f
Quote: refer to 1st floor all Java stack route reply:
characterEncoding=role is to specify the processing characters of decoding and encoding format, or standard,

Thank you, what you mean?
First save my database list of characters, is utf-8, also may be GBK code
I want to achieve, the database either utf-8 or GBK, saved to a String or HASMAP are unified into utf-8
Consult how to do?
Thank you


This can only judge for yourself in the code to handle, if your database utf-8 with GBK points, it is easy to cause garbled question, best unified coding format,

For example, mysql database using GBK code, and the project using utf-8, if added useUnicode=true& CharacterEncoding=utf-8, so has the following two aspects:
Save data:
When a database to store project data will use utf-8 first decoding data into bytecode, then after decoding the bytecode to GBK code stored in the database,

Take data:
When fetching data from the database, the database will be according to the data from the database GBK format decoding into bytecode, then after decoding the bytecode to press utf-8 encoded data, and then the data returned to the client,

CodePudding user response:

refer to the second floor old zizhu reply:
, such as the upstairs said, if you specify different server code and, when the server will read and return, automatic to do encoding conversion,
Again, you read from the local data, such as is GBK, if encoding and you specified is not the same, specifies the UTF8, for example, you have nothing to take the initiative to transfer from GBK code UTF8, that will cause the database of data processing error,

Thanks for a great god, and is not very understanding

CodePudding user response:

Server is UTF8 character set, your local data is GBK, what would you do?
Whereas also have this problem,
  • Related