Correctly set the collation of H2 database to solve Chinese sorting problem __ Database

Source: Internet
Author: User

In the case of not setting the collation, the sorting result of the Chinese text is chaotic to find this phenomenon, set collation to Chinese_china look (note that the settings collation to not create any tables in the database OH), set Collation Chinese_china

The results are still not satisfactory, although the vast majority of record sorting is correct (in alphabetical order), but still have a small number of relatively uncommon words to be ranked alone in the last. Imagine if a leader's name in alphabetical order should be ranked in the front, the result because of the rare word to the end, was led to find out will not be happy to give you a shoe to wear it. What to do with perfection. Checking out the H2 documentation, you can call ICU4J (ICU for Java) to replace the built-in collation mechanism when setting up collation. (Do not know ICU, you out of it, want to Google first.) )。 Download the Icu4j.jar to the ICU website, add it to the classpath, and restart the H2 service. Create the database again, and, immediately after creating the database, enter the following command without creating the table Collation:set collation Icu4j_chinese_china

Again, if you have already created a table, this command is invalid. After setting collation to Icu4j_chinese_china, the Chinese sort will be OK.

From: http://www.cnblogs.com/agateriver/archive/2012/04/21/h2_collation.html

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.