Modified:
branches/branch_3_1/connector-j/CHANGES
branches/branch_3_1/connector-j/src/com/mysql/jdbc/CharsetMapping.java
Log:
Fixed BUG#14938 - Unable to initialize character set mapping tables.
Removed reliance on .properties files to hold this information, as it
turns out to be too problematic to code around class loader hierarchies
that change depending on how an application is deployed. Moved information
back into the CharsetMapping class.
Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES 2006-01-30 01:01:09 UTC (rev 4872)
+++ branches/branch_3_1/connector-j/CHANGES 2006-01-30 17:30:45 UTC (rev 4873)
@@ -23,6 +23,12 @@
- Fixed BUG#15854 - DBMD.getColumns() returns wrong type for BIT.
+ - Fixed BUG#14938 - Unable to initialize character set mapping tables.
+ Removed reliance on .properties files to hold this information, as it
+ turns out to be too problematic to code around class loader hierarchies
+ that change depending on how an application is deployed. Moved information
+ back into the CharsetMapping class.
+
11-30-05 - Version 3.1.12
- Fixed client-side prepared statement bug with embedded ? inside
Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/CharsetMapping.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/CharsetMapping.java 2006-01-30
01:01:09 UTC (rev 4872)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/CharsetMapping.java 2006-01-30
17:30:45 UTC (rev 4873)
@@ -24,9 +24,6 @@
*/
package com.mysql.jdbc;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
@@ -65,33 +62,82 @@
private static final Map MYSQL_TO_JAVA_CHARSET_MAP;
- static {
- InputStream inStream = CharsetMapping.class
- .getResourceAsStream("/com/mysql/jdbc/Charsets.properties");
+ static {
+
+ CHARSET_CONFIG.setProperty("javaToMysqlMappings",
+ //
+ // Note: This used to be stored in Charsets.properties,
+ // but turned out to be problematic when dealing with
+ // Tomcat classloaders when the security manager was
+ // enabled
+ //
+ // Java Encoding MySQL Name (and version, '*'
+ // denotes preferred value)
+ //
+ "US-ASCII = usa7,"
+ + "US-ASCII = ascii,"
+ + "Big5 = big5,"
+ + "GBK = gbk,"
+ + "SJIS = sjis,"
+ + "EUC_CN = gb2312,"
+ + "EUC_JP = ujis,"
+ + "EUC_JP_Solaris = >5.0.3 eucjpms,"
+ + "EUC_KR = euc_kr,"
+ + "EUC_KR = >4.1.0 euckr,"
+ + "ISO8859_1 = *latin1,"
+ + "ISO8859_1 = latin1_de,"
+ + "ISO8859_1 = german1,"
+ + "ISO8859_1 = danish,"
+ + "ISO8859_2 = latin2,"
+ + "ISO8859_2 = czech,"
+ + "ISO8859_2 = hungarian,"
+ + "ISO8859_2 = croat,"
+ + "ISO8859_7 = greek,"
+ + "ISO8859_7 = latin7,"
+ + "ISO8859_8 = hebrew,"
+ + "ISO8859_9 = latin5,"
+ + "ISO8859_13 = latvian,"
+ + "ISO8859_13 = latvian1,"
+ + "ISO8859_13 = estonia,"
+ + "Cp437 = *>4.1.0 cp850,"
+ + "Cp437 = dos,"
+ + "Cp850 = Cp850,"
+ + "Cp852 = Cp852,"
+ + "Cp866 = cp866,"
+ + "KOI8_R = koi8_ru,"
+ + "KOI8_R = >4.1.0 koi8r,"
+ + "TIS620 = tis620,"
+ + "Cp1250 = cp1250,"
+ + "Cp1250 = win1250,"
+ + "Cp1251 = *>4.1.0 cp1251,"
+ + "Cp1251 = win1251,"
+ + "Cp1251 = cp1251cias,"
+ + "Cp1251 = cp1251csas,"
+ + "Cp1256 = cp1256,"
+ + "Cp1251 = win1251ukr,"
+ + "Cp1257 = cp1257,"
+ + "MacRoman = macroman,"
+ + "MacCentralEurope = macce,"
+ + "UTF-8 = utf8,"
+ + "UnicodeBig = ucs2,"
+ + "US-ASCII = binary,"
+ + "Cp943 = sjis,"
+ + "MS932 = sjis,"
+ + "MS932 = >4.1.11 cp932,"
+ + "WINDOWS-31J = sjis,"
+ + "WINDOWS-31J = >4.1.11 cp932,"
+ + "CP932 = sjis,"
+ + "CP932 = *>4.1.11 cp932,"
+ + "SHIFT_JIS = sjis,"
+ + "ASCII = ascii,"
+ + "LATIN5 = latin5,"
+ + "LATIN7 = latin7,"
+ + "HEBREW = hebrew,"
+ + "GREEK = greek,"
+ + "EUCKR = euckr,"
+ + "GB2312 = gb2312,"
+ + "LATIN2 = latin2");
- if (inStream == null) {
- throw new RuntimeException(
- "Unable to initialize character set mapping tables");
- }
-
- try {
- CHARSET_CONFIG.load(inStream);
- inStream.close();
- inStream = null;
- } catch (IOException ioEx) {
- throw new RuntimeException(
- "Unable to initialize character set mapping tables");
- } finally {
-
- if (inStream != null) {
- try {
- inStream.close();
- } catch (IOException ioEx) {
- // do nothing, can't handle it here
- }
- }
- }
-
HashMap javaToMysqlMap = new HashMap();
populateMapWithKeyValuePairs("javaToMysqlMappings", javaToMysqlMap,
@@ -149,6 +195,38 @@
//
HashMap tempMapMulti = new HashMap();
+ CHARSET_CONFIG.setProperty("multibyteCharsets",
+ //
+ // Note: This used to be stored in Charsets.properties,
+ // but turned out to be problematic when dealing with
+ // Tomcat classloaders when the security manager was
+ // enabled
+ //
+ // Java Name MySQL Name (not currently used)
+ //
+
+ "Big5 = big5,"
+ + "GBK = gbk,"
+ + "SJIS = sjis,"
+ + "EUC_CN = gb2312,"
+ + "EUC_JP = ujis,"
+ + "EUC_JP_Solaris = eucjpms,"
+ + "EUC_KR = euc_kr,"
+ + "EUC_KR = >4.1.0 euckr,"
+ + "Cp943 = sjis,"
+ + "Cp943 = cp943,"
+ + "WINDOWS-31J = sjis,"
+ + "WINDOWS-31J = cp932,"
+ + "CP932 = cp932,"
+ + "MS932 = sjis,"
+ + "MS932 = cp932,"
+ + "SHIFT_JIS = sjis,"
+ + "EUCKR = euckr,"
+ + "GB2312 = gb2312,"
+ + "UTF-8 = utf8,"
+ + "utf8 = utf8,"
+ + "UnicodeBig = ucs2");
+
populateMapWithKeyValuePairs("multibyteCharsets", tempMapMulti, false,
true);
| Thread |
|---|
| • Connector/J commit: r4873 - in branches/branch_3_1/connector-j: . src/com/mysql/jdbc | mmatthews | 30 Jan |