Bug #8843 SQLException: Unknown initial character set index '202'
Submitted: 28 Feb 2005 14:23 Modified: 3 Mar 2005 22:23
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.7 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[28 Feb 2005 14:23] [ name withheld ]
Description:
Using Connector/J against mysql server in utf8 mode ends up with the folowing exception:

java.sql.SQLException: Unknown initial character set index'202' received from server, even if I pass 

useUnicode=true&characterEncoding=utf8 properties to the new driver instance.

How to repeat:

use default charset utf8 for mysql 4.1.10 and try to connect to with Connector/J
[28 Feb 2005 15:59] Mark Matthews
I wasn't able to repeat this with my local build of 4.1.10. What does your share/mysql/charsets/Index.xml file look like? Does it have utf8 listed as charset number 202?
[28 Feb 2005 17:07] [ name withheld ]
utf-8 is compiled-in charset, but to be sure, I added the 202 for my utf8_czech_ci collation. It makes no difference for me. My connect string:

jdbc:mysql://127.0.0.1/?useUnicode=true&characterEncoding=utf8

It is not my own program, which has the problems - it fails while creating Scarab database. And I hope the server is set properly:

mysql> show variables like '%char%';
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8                             |
| character_set_connection | utf8                             |
| character_set_database   | utf8                             |
| character_set_results    | utf8                             |
| character_set_server     | utf8                             |
| character_set_system     | utf8                             |
| character_sets_dir       | /usr/local/share/mysql/charsets/ |
+--------------------------+----------------------------------+
7 rows in set (0.13 sec)

mysql> show variables like '%collat%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_czech_ci   |
| collation_server     | utf8_czech_ci   |
+----------------------+-----------------+
3 rows in set (0.01 sec)

A piece of charsets/Index.xml:

<charset name="utf8">
  <family>Unicode</family>
  <description>UTF-8 Unicode</description>
  <alias>utf-8</alias>
  <collation name="utf8_general_ci"     id="33">
   <flag>primary</flag>
   <flag>compiled</flag>
  </collation>
  <collation name="utf8_bin"            id="83">
    <flag>binary</flag>
    <flag>compiled</flag>
  </collation>
  <collation name="utf8_czech_ci"            id="202">
    <flag>compiled</flag>
  </collation>
</charset>

Also setting '202' to be a primary utf8-collation makes no difference.
[1 Mar 2005 10:11] [ name withheld ]
Well, I resolved the issue - it is probably related to scarab (badly formed connection string), not to mysql connector/j. What I have to do on the mysql side was adding utf8_czech_ci collation to charsets/Index.xml (as I was adviced here) and explicitly using characterEncoding=ut8 as a connection property.

Sorry for wasting your time. I wrote my own test in java which led me to the right decision where the problem lies.