| Bug #44773 | Chinese database name in JDBC connection string is not working | ||
|---|---|---|---|
| Submitted: | 11 May 2009 5:56 | Modified: | 21 May 2009 10:03 |
| Reporter: | Zunil John | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 5.0.8 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | Chinese database, connection string | ||
[11 May 2009 8:37]
Tonci Grgin
Hi Zunil and thanks for your report. Can you do two things for me please: o check if you can attach to that database from command line client o upgrade to c/J 5.1 as 5.0 is EOL-ed
[11 May 2009 8:48]
Tonci Grgin
A colleague of mine did some testing and here's what she found: o All characters appear to be 3byte UTF8 so it should work if o on Win and current CP supports those characters o or on Linux and system locale is UTF8 So, which OS do you use and how is it set up? Please attach my.cnf.ini file and paste output of SHOW VARIABLES LIKE '%char%'; command.
[11 May 2009 13:28]
Zunil John
SHOW VARIABLES LIKE '%char%' is haracter_set_client utf8 character_set_connection utf8 character_set_database utf8 character_set_filesystem binary character_set_results utf8 character_set_server latin1 character_set_system utf8 character_sets_dir D:\Program Files\MySQL\MySQL Server 5.0\share\charsets\ I am using Windows OS nad my Windows character set is CP1252. The DB is created with UTF8 character set. I am attching my.ini. The database characterset is latin1. My question is 1. Is it required that DB server is UTF8? I will have multiple DB's on the same server with different character set. 2. Connection string is a jaav string. Other things like table names in chines, queries containing chinese all works. Only DB name in connection string is not working.
[11 May 2009 13:28]
Zunil John
My.ini file
Attachment: my.ini (application/octet-stream, text), 8.73 KiB.
[21 May 2009 10:03]
Tonci Grgin
Zunil, you should definitely change character_set_server to utf8. The option --characterset-server is used to initialize all new client connections to a default characterset, which is, in your case, latin1. Thus it is not possible to use GBK chars in database name while connecting as they simply fall out of latin1 bmp.

Description: I have a database with Chinese name(ex:中國話的) in MySQL 5.0.67. But when I try to use this database inside my Java program in the connection string, it throws error. You will get com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown database '????' Example code package com.test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class MySQLTest { public static void main(String[] args) { Connection con = null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager .getConnection( "jdbc:mysql://<<servername>>/中國話的?useUnicode=true&characterEncoding=UTF-8", "user", "password"); } catch(Exception e) { e.printStackTrace(); } } } Is this a known issue with MySQL JDBC driver nad is there nay solution to this? How to repeat: 1. Create a DB with Chinese name in MySQL server 2. Write a java program or copy the above sample code to a file name MySQLTest .java 3. Set MySQL JDBC driver(I tested with 5.0.8) in class path 4. Compile and run the java program 5. You will get a stack trace