Perfect solution to the Chinese garbled problem of Informix

Source: Internet
Author: User
Tags informix

Perfect solution to the Chinese garbled problem of InformixInformix is a database of IBM, but for this project, I don't know if I have a database in my life. Want to the company's projects across the country, a variety of deployment environment, a variety of application scenarios, 7788 asked a lot of the project group of brothers, incredibly no one knows this thing, it can be seen that the goods have a small number of people ...

Just beginning to touch this thing completely puzzled, its design concept and use method is too strange, whether it is DB2, Oracle, or MySQL, incredibly not a corresponding development experience can be directly applied to Informix, is to find the corresponding documents are more laborious than other databases, Other do not say, light this Chinese garbled problem, I also took a kung fu just toss good.

Nonsense not to say, to solve the garbled process of various egg pain for a while, go straight to the topic, first put their own experience and solve the problem of a few key points to record:

Key one: The four basic concepts necessary for a proper understanding of the Informix database.

The meanings of four locales:

1, client language environment-client locale
The client locale specifies the language, geography, and code set that the client application uses to perform read and write (I/O) operations.
In a client application, I/O operations include reading keyboard input or data files to be sent to a database, and writing data retrieved from the database server to a screen, file, or printer.
Set up the client locale through Client_locale.

2, Database language environment-database locale
Specify the language, geography, and code set required by the database server to correctly interpret the data types (NCHAR and NVARCHAR) that are relevant to the locale in a particular database by using the DB_LOCALE environment variable setting database locale.
The code set specified in Db_locale determines which characters are valid for any word columns, and determines the names of database objects such as databases, tables, columns, and views.
The database server uses the database code set specified by the Db_locale environment variable to pass data to and from the database.

3, Server language environment-server locale
The database server writes files (such as Debug and warning files) using the server code set specified by the Server_locale environment variable.
However, the database server does not use the server locale to write files (databases and table files) in the Informix-specific format.

4, Server processing language environment-server processing locale
The database server uses the code set of the database locale as the code set for the server processing locale, using the server processing locale to write files in the Informix-specific format (database and table files).
This means that the database server uses the database locale (Db_locale) to write files in the Informix-specific format (database and table files).


Key point two: Introduce the correct JDBC jar file.
A list of jar files is as follows, and the jar file requires at least these 10, which is indispensable:
Ifxjdbc.jar
Ifxjdbc-g.jar
Ifxjdbcx.jar
Ifxjdbcx-g.jar
Ifxlang.jar
Ifxlsupp.jar
Ifxsqlj.jar
Ifxsqlj-g.jar
Ifxtools.jar
Ifxtools-g.jar

This key point is very important to emphasize: Theoretically, let Informix start up only need Ifxjdbc.jar, but no other jar file, your Chinese problem will never solve! Lao Tzu was the only introduction of the necessary five or six jar, to the end of the tune is not correct this garbled, at this point spent most of the time.

Key point three: View all the database encodings under the current system.
SELECT * FROM Sysmaster:sysdbslocale
The statement can query the encoding format used by all databases in the current database.

Key point four: Write the correct JDBC URL.

JDBC URL (UTF-8 encoding example):
JDBC:INFORMIX-SQLI:6.1.14.38:48101/CCDB2:INFORMIXSERVER=CCDB; newcodeset=utf8,8859-1,819; client_locale=en_us.utf8;db_locale=en_us.8859-1;

JDBC URL (GBK encoding example):
JDBC:INFORMIX-SQLI:6.1.14.38:48101/CCDB2:INFORMIXSERVER=CCDB; newcodeset=gb18030-2000,8859-1,819; Client_locale=zh_cn.gb;db_locale=zh_cn.gb;dbdate=mdy4;ifx_use_strenc=true;

This point must also emphasize that its importance is second only to the key point two. In Java, the encoding we use is called UTF-8, but in Informix, the correct writing of this encoding format is UTF8, not utf-8! In addition, GBK encoding in the Informix system is called GB or gb18030-2000, if you write in the URL GBK is not recognized.


Key point Five: Verify that the Informix server supports the UTF-8 format.
Use the Locale-a command, and then check to see if ZH_CN is supported. UTF8 (Note en_US. UTF-8 also available)

Key point six: Encoding adjustment for the Client Connection tool.
Note: Use SECURECRT to display ZH_CN. When UTF8 characters, you should select UTF-8 in the exact font of the terminal----------end of session options, otherwise the garbled text will be displayed.

Summarize:

Key point two, the key point four is to solve the problem of Informix garbled, as long as these two key points no problem, Chinese will certainly be able to read and write to the database. Also, it is important to note that this solution is only for Informix deployed on Linux/unix and the test is valid. A set of databases, actually deployed on the Windows server, too plunges, this situation is completely ignored.

Perfect solution to the Chinese garbled problem of Informix

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.