when using JDBC to connect to the Mysql database and insert a record with Chinese into the Mysql database, it is found that they are all?
here is a picture description
to query some information. The simplest solution is as follows:
1: set the encoding of the current database
ALTER DATABASE zhongfucheng
CHARACTER SET utf8;
2: set the encoding of the current table
ALTER TABLE customer
CHARACTER SET utf8;
3: specify the encoding when using JDBC to connect to the database
jdbc:mysql://localhost:3306/zhongfucheng?characterEncoding=utf8
when we complete these three steps, insert the data again: that's it
it seems that you have not specified the encoding to be used when connecting to the database, so the default encoding of the system will be used, and the default encoding may be different between the two systems.
I guess your database code should be gbk?. Therefore, the coding of the local Chinese environment is the same as that of the database, while the default of centos may not be gbk.
No encoding was specified when configuring the database connection