java - How to check (or even set) collation in mdb (ms access) file? -
i succesfully migrated access db mysql db. seems fine need more specific behaviour of mysql db.
need same sorting of query result in access db after choose option "sort z".
use result in java application.
mysql table utf-8 , collation set utf8_general_ci.
example query is:
"select encode, language suffixes order encode collate utf8_unicode_ci"
it returns similar result there unacceptable differences in sorting.
access sorts result this:
001_01._02.1_02.2.1_02.4_05.e.3.1_07.2.2_15.5.d_20.3.2.1_31.2.2_33.3.4_001 001_01._02.1_02.4.1_06.4.1_06.4.2_07.2.1.1_07.2.2_10.1_11.1.3_20.3.2.1_20.3.7_20.6.8_001
java sorts result this:
001_01._02.1_02.2.1_02.4_05.e.3.1_07.2.2_15.5.d_20.3.2.1_31.2.2_33.3.4_001 001_01._02.1_02.4_06.1_06.2.4.1.2_06.2.4.1.3_06.3.1_07.2.1.1_07.2.2.1_11.2.2_15.2.1.a.1_15.5.a_20.3.2.2.1.a_20.7.1.5_20.8_33.4.5.3_001
additionaly don't know how check charset , collation in access.
can give me hint should obtain proper results?
i figured out. used collator class proper sorting.
fyi looks (this sorting of arraylist):
public class accesssorter { final static string letters = "< a, < b, b < c, c < d, d < e, e < f, f < g, g < h, h < i, < j, j < k, k < l, l < m, m < n, n < o, o < p, p < q, q < r, r < s, s < t, t < u, u < v, v < w, w < x, x < y, y < z, z"; final static string digits = "< 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9"; final static string special = "< '.' < '_'"; private rulebasedcollator accesscollator; accesssorter() { try { accesscollator = new rulebasedcollator(special + digits + letters); } catch (parseexception e) { e.printstacktrace(); } } somecomparator getsomecomparator() { return new somecomparator(); } class somecomparator implements comparator<string[]> { @override public int compare(string[] s1, string[] s2) { return accesscollator.compare(s1[1], s2[1]); } }
}
example of usage:
collections.sort(somecollectionofstringarray, new accesssorter().getsomecomparator()
and don't need worry collations of access or mysql. set rules yourselve. of course takes time sort such array.
remember, if need sort big arrays more once, consider using of getcollatorkey() increase efficiency.
remember if need add collator semicolons, periods, quotation marks put them ' '.
hope somehow. regards.
Comments
Post a Comment