Character encoding when inserting Chinese Characters in Oracle

Source: Internet
Author: User

Background:

Myeclipse character encoding GBK

Oracle Database character encoding GBK

The character encoding UTF-8 that inserts content from a third party using the webservice Interface

Problem description:

Pre-compiled by java PreparedStatement to enter the insert operation, run SQL exception, baidu character encoding problem, after several transcoding methods is still fruitless, the final work und

Work und:

The insert statement is used to concatenate an SQL statement. Because the current myeclipse environment is GBK encoded, the Chinese characters in the inserted statement are converted to GBK encoding by default. The insert operation is normal.

The concatenated SQL statement is as follows:

  1. String SQL ="Insert into t_ivr_jobs_info_bak (JOBID, JOBTYPE, JOBAREA, JOBINFO) values ("+ JobId +",'"+ JobType +"','"+ JobCity +"','"+ JobInfo +"')";

Summary

PreparedStatement. setString (index, str); should be directly connected to the database. In this process, the str character encoding is still UTF-8. If no conversion is made, an exception occurs when the database is directly inserted. The encoding format is inconsistent.

After splicing the preceding SQL statements, the variables are displayed in the current environment, which is converted to the GBK format by default. Therefore, the encoding inconsistency is avoided when inserting the variables,

However, you cannot bind variables to improve performance. However, sometimes performance is not the most important thing.

Related Article

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.