Client sending-Servlet executes SQL statement to insert Chinese characters into MySql. at this time, the Chinese characters in MySql are changed to blocks and garbled characters

Source: Internet
Author: User
The Android client has a login registration program. when registering, enter the user name and password. the client uploads the form data to the Servlet in The GET mode, and then the Servlet uses Stringnamerequest. getParameter (& quot; username & quot;); Stringpasswordrequest. getParameter (& quot; password & quot;); obtain the user name and password, and then execute the SQL statement to insert the user name and password into MySql. this is the whole process, in addition, if the user name and password are composed of only numbers and letters, the client can normally send the mysqltomcat Android garbled code.

The Android client has a login registration program. when registering, enter the user name and password. the client uploads the form data to the Servlet in The GET mode, and then the Servlet uses String name = request. getParameter ("username"); String password = request. getParameter ("password"); get the user name and password, and then execute the SQL statement to insert the user name and password into MySql. this is the whole process, in addition, the user name and password can be added to the database normally only when they are composed of numbers and letters. The problem arises. when I input the user name as a Chinese character, it turns into a square when I insert it into the database, that is, garbled characters ??.. How can this problem be solved? I have searched the internet for a long time. This Post says that I set what to be GBK, that post says that I set what to be GB2312, and that post says that I set what to be UTF8, I am confused. how should I set it ??? I am a little white, and sometimes I don't understand the solutions written by those great gods... Helpless .. Now I want to know, it must be code like adding transcoding, right ??? Is transcoding received by the server when the client is sent and then transcoded before being inserted into the database ?? So what is the code... I only scored 5 points, so I took all of them out ..

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.