| Bug #10496 | SQLException is thrown when using property "characterSetResults" | ||
|---|---|---|---|
| Submitted: | 10 May 2005 1:05 | Modified: | 24 May 2005 9:38 |
| Reporter: | Tetsuro Ikeda | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | 3.1.8 nightlybuild 20050504 | OS: | Windows (Windows2000Pro) |
| Assigned to: | CPU Architecture: | Any | |
[10 May 2005 1:10]
Tetsuro Ikeda
added the information about version (3.1.8 nightlybuild 20050504) and charset (WINDOWS-31J, MS932)
[10 May 2005 15:43]
Tetsuro Ikeda
Added os info, win2k pro, and the server version is here MySQL 5.0.4beta-nt :p
[19 May 2005 9:58]
Vasily Kishkin
I tested your example against mysql server 5.0.6-nt beta and did't get any exception. Could you please try latest mysql server and let us know if the problem remains.
[19 May 2005 10:16]
Tetsuro Ikeda
Sorry about not updating this issue. Already I wrote patch and Mark pushed it to the CVS. I can see Connector/J 3.1 nightlybuild 20050519 got fixed. The fix way is not changing the calling sequence but add some code to the CharasetMapping.java's static initializer which initializes INDEX_TO_MYSQL for recieving data as variety of charsets. The patch fixed not only cp932 but also eucjpms.
[19 May 2005 10:18]
Tetsuro Ikeda
Oops, I mean INDEX_TO_CHARSET, not INDEX_TO_MYSQL.
[24 May 2005 9:38]
Vasily Kishkin
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at http://www.mysql.com/downloads/

Description: When Connecting by using property "characterSetResult" with value "WINDOWS-31J" or "MS932" such as being mapped "cp932" in MySQL Server, SQLException is thrown and error message shows the following. java.sql.SQLException: Unknown character set index for field '95' This exception is thrown when Connector/J is doing one of intial queries "SHOW VARIABLES" How to repeat: like the following: String url = "jdbc:mysql://localhost/test"; Properties props = new Properties(); props.put("user", "root"); props.put("password", ""); props.put("useUnicode", "true"); props.put("characterEncoding", "WINDOWS-31J"); props.put("characterSetResults", "WINDOWS-31J"); Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection(url, props); Suggested fix: After the "SHOW COLLATION" in the Connector/J's initial queries, cp932 is set on the CharsetMapping.INDEX_TO_CHARSET. But before that, not yet. So, "SHOW VARIABLES" before "SHOW COLLATION" cause this exception.