[kaffe] java.lang.ClassCastException

Lam King Tin ktlam at cs.hku.hk
Sat Dec 16 07:56:42 PST 2006


Dear Jim,

Deep thanks for your debugging. 
But I do see the 7th alias should match, am I right?
That is:  alias.put("ISO8859_1",		"8859_1");
So I still can't understand why this error comes out.

Best regards,
King Tin


Quoting Jim White <jim at pagesmiths.com>:

> Lam King Tin wrote:
> 
> > Dear Jim,
> > 
> > Thank you very much for your reply. 
> > 
> > I have tried to replace the method with the fixed version from Connector/J
> 5.0 
> > as follows. The casting exception has disappeared. However, now I always 
> > encounter below. This encoding should be the most common, right? But why
> this 
> > happens. Thanks.
> > 
> > SQL Exception:  Unsupported character encoding 'ISO8859_1'.
> > ...
> 
> Well, more debugging shows that Connection has tried all of the 
> configurable character encodings it knows on tests that look like this:
> 
> mysql-connector-java-3.0.17-ga/com/mysql/jdbc/Connection.java
> 
>     private void configureCharsetProperties(Properties info) throws 
> SQLException {
> ...
>     try {
>        String testString = "abc";
>        testString.getBytes(this.encoding);
>     } catch (UnsupportedEncodingException encodingEx) {
>        throw new SQLException("Unsupported character "
>              + "encoding '" + this.encoding + "'.",
>           SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE);
>     }
> 
> And the last try must be from this:
> 
>      private boolean configureClientCharacterSet() throws SQLException {
>          String realJavaEncoding = getEncoding();
>          boolean characterSetAlreadyConfigured = false;
> 
> ...
> 
>           if (this.encoding == null) {
>               // punt?
>               this.encoding = "ISO8859_1";
>           }
> 
> So I look into Kaffe 1.0.6 to find out how character encodings are 
> configured (fortunately or unfortunately depending on how you look at 
> it, I've done a fair bit of this sort of thing before...) and we see this:
> 
> kaffe-1.0.6/libraries/javalib/kaffe/io/CharToByteConverter.java
> 
> private static CharToByteConverter getConverterInternal(String enc)
> {
> ...
>     String realenc = encodingRoot + ".CharToByte" + 
> ConverterAlias.alias(enc);
> 
> kaffe-1.0.6/libraries/javalib/kaffe/io/ConverterAlias.java
> 
> public class ConverterAlias {
>      private static final Hashtable alias = new Hashtable();
> 
>      // All aliases should be upper case
>      static {
>     alias.put("DEFAULT",    "Default");
>     alias.put("ISO-8859-1",    "8859_1");
>     alias.put("ISO_8859_1",    "8859_1");
>     alias.put("ISO 8859-1",    "8859_1");
>     alias.put("ISO 8859_1",    "8859_1");
>     alias.put("ISO_8859-1",    "8859_1");
>     alias.put("ISO8859_1",     "8859_1");
>     alias.put("ISO-IR-100",    "8859_1");
>     alias.put("LATIN1",     "8859_1");
>     alias.put("L1",         "8859_1");
>     alias.put("IBM819",     "8859_1");
>     alias.put("CP819",      "8859_1");
>     alias.put("CSISOLATIN1",   "8859_1");
>     alias.put("ISO-8859-2",    "8859_2");
>     alias.put("ISO-8859-3",    "8859_3");
>     alias.put("ISO-8859-4",    "8859_4");
>     alias.put("ISO-8859-5",    "8859_5");
>     alias.put("ISO-8859-6",    "8859_6");
>     alias.put("ISO-8859-7",    "8859_7");
>     alias.put("ISO-8859-8",    "8859_8");
>     alias.put("ISO-8859-9",    "8859_9");
>     alias.put("ISO-2022-JP",   "EUC_JP");
>     alias.put("EBCDIC",     "CP1046");
>     alias.put("UTF-8",      "UTF8");
>     alias.put("KOI8-R",     "KOI8_R");
>     /* add more here */
>      }
> 
> So we see that "ISO8859_1" is not an alias kno.  Try changing that line 
> in Connector.java to use one like "ISO-8859-1".  That should get you 
> past the initial failure, but whether you'll have a working 
> configuration may a bit doubtful.
> 
> Jim
> 
> 


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/




More information about the kaffe mailing list