Java.sql.SQLException:Incorrect string value: ' \xe6\x88\x91\xe7\x9a\x84 ... ' for column ' GroupName ' at row 1
Very tangled, I thought it should be one of the following:
(1). Data encoding setting error when creating database
(2). Data encoding Setup error when connecting to database
for (1), I delete the original database, re-create a new database when setting the encoding, my settings are as follows:
Character Set:utf8--UTF-8 Unicode
Collation:utf8_general_ci
After discovering this setting, this problem cannot be resolved.
for (2), I write the connection statement as:
"jdbc:mysql://" + IP + ": 3306/users?useunicode=true&characterencoding=utf8"
But the problem is still unresolved.
I also carefully observed the program I wrote, found in the program to create a table in the database operation, the following statement:
"CREATE TABLE Friendslist (QQ varchar (7) Primary Key,remark varchar (), groupName varchar (20));"
In this way, the problem becomes clear, the original creation of each table must set the data encoding method, the following statement:
"CREATE TABLE Friendslist (QQ varchar (7) Primary Key,remark varchar (), groupName varchar) charset UTF8 collate utf8_ General_ci; "
To summarize, there are several reasons why the title of this article has the following problems:
(1). Data encoding setting error when creating database
(2). Data encoding Setup error when connecting to database
(3). Data encoding settings error when creating a table
Java.sql.SQLException:Incorrect string value: ' \xe6\x88\x91\xe7\x9a\x84 ... ' for column ' GroupName '