Oracle client and server-side character Set principle (transfer from TOTOZLJ)

Source: Internet
Author: User

1. Environmental assumptions:

Noun Explanation: The application page is the page that the user sees in the browser, the general clerk will write the page in the page to set the code, this code is the data in the browser to the Web server transmission between the encoding, if not set the default iso-8859 encoding, this encoding does not support Chinese.

In general, the page of the Java EE Project will be many, now take two pages to explain, respectively, page 1, page 2, page 1 encoded as UTF-8, page 2 is encoded as GBK.

Oracle's client configuration content is as follows:

Sql> select * from Nls_instance_parameters;

PARAMETER VALUE
-------------------------------------------------- --------------------------------------------------
Nls_language Simplified Chinese
Nls_territory China

The database character set contents are as follows:

Sql> select * from Nls_database_parameters;

PARAMETER VALUE
-------------------------------------------------- --------------------------------------------------
Nls_language AMERICAN
Nls_territory AMERICA
Nls_currency $
Nls_iso_currency AMERICA
Nls_numeric_characters.,
Nls_characterset Al32utf8
Nls_calendar Gregorian
Nls_date_format DD-MON-RR
Nls_date_language AMERICAN
Nls_sort BINARY
Nls_time_format HH.MI. Ssxff AM

PARAMETER VALUE
-------------------------------------------------- --------------------------------------------------
Nls_timestamp_format DD-MON-RR HH.MI. Ssxff AM
Nls_time_tz_format HH.MI. Ssxff AM TZR
Nls_timestamp_tz_format DD-MON-RR HH.MI. Ssxff AM TZR
Nls_dual_currency $
Nls_comp BINARY
Nls_length_semantics BYTE
NLS_NCHAR_CONV_EXCP FALSE
Nls_nchar_characterset AL16UTF16
Nls_rdbms_version 11.1.0.6.0

Linux under the LANG=ZH_CN. UTF-8

2. Problem: User operation: Page 1, enter Chinese "China", page 2, enter Chinese "China", this time the problem appears, in page 1 to view page 2 of the input Chinese record is garbled, in page 2 to view the Chinese record entered in Page 1 is garbled.

3, Problem analysis:

Oracle does this to store data, and when the data passes through the browser, the Oracle database first asks the Oracle client, asks what the data is encoded, and then the Oracle client checks the NLS_LANG environment variable, if the environment variable is not configured, The database character set is used by default, and here is Al32utf8, if configured, the Oracle client will tell the Oracle database Nls_lang value, in which case the Nls_lang environment variable is not set. So the Oracle client defaults to using the database character set, which is Al32utf8, and China in Page 1 is routed to the database using UTF-8 encoding, so the Oracle client tells the Oracle database side to store this data using AL32UTF8 encoding, which is consistent with the database character set , so the database without transcoding direct storage, when the query is also directly detected without transcoding, so the data from the database to the page are used Utf-8 pass, and really to page 2 when the page 2 is found to use the GBK code, at this time garbled. This is also the case for viewing page 2 input in Page 1.

4. Summary:

The Oracle client character set is best matched to the database-side character set, which eliminates a transcoding process in the database and improves database performance.

Setting up a client character set and a database-side character set in Oracle now seems to save the process of transcoding the database, and nothing else has been found.

The client character set and the Web server now seem to have nothing to do with the encoding settings in the page, and the Web server is nothing more than a transit point for data.

The encoding of database server Linux is only related to the Chinese display of the terminal connection of SCRT, which is independent of the application data encoding. such as Linux's LANG=ZH_CN. UTF-8 The SCRT can display Chinese, if the other does not support the Chinese encoding, it will not display the normal Chinese.

Reference article: http://blog.csdn.net/nini1109/article/details/4158796

http://www.oschina.net/question/234345_51169

http://hi.baidu.com/wwcs_new/item/69af38448c02f416886d1067

http://xiangqinghu1988.blog.163.com/blog/static/58822991201222231517193/

Http://www.cnblogs.com/kelin1314/archive/2011/01/21/1940986.html

http://yangzb.iteye.com/blog/255769

http://blog.csdn.net/woods2001/article/details/7238690

http://jelly.iteye.com/blog/654300

http://xuejianxinokok.blog.163.com/blog/static/40437577201212332037607/

http://jelly.iteye.com/blog/654300

Http://www.cnblogs.com/dongzhiquan/archive/2012/06/26/2564134.html

Oracle client and server-side character Set principle (transfer from TOTOZLJ)

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.