MVC design pattern for user Registration form submission to database Chinese garbled problem

Source: Internet
Author: User
Tags mysql in

This article references from: http://blog.csdn.net/wangchangshuai0010/article/details/12714575Java.sql.SQLException:Incorrect string value: ' \xe6\x88\x91\xe7\x9a\x84 ... ' for column ' GroupName ' 

Today, using MySQL to write data to MySQL in a Java program, the following error occurred:

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

For example:

Create DATABASE myuser default character set UTF8 collate 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 u tf8_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

  

CREATE DATABASE myuser default character set UTF8 collate utf8_general_ci;

(2). Data encoding Setup error when connecting to database

"jdbc:mysql://" + IP + ": 3306/users?useunicode=true&characterencoding=utf8"

(3). Data encoding settings error when creating a table

"CREATE TABLE Friendslist (QQ varchar (7) Primary Key,remark varchar (), groupName varchar) charset UTF8 collate utf8_ General_ci; "

MVC design pattern for user Registration form submission to database Chinese garbled problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.