Description:
I worked under Chinese Windows2000pro with sp3, my local language is set to GBK.
I have the mysql server 4.0.12 installed, and add a line into c:\winnt\my.ini at section [mysqld] :
default-character-set=gbk
By the way, the string "gbk" must be lower case, or the server can't be started.
I use mysql-connector-java-3.0.7-stable.zip, and found the problem that, in java programs, if I insert a Chinese String into a table useing j-connector-3.0.7, both encoding and decoding is wrong. one solution is
connection = DriverManager.getConnection( "jdbc:mysql://localhost/test?user=root&password=&useUnicode=true&characterEncoding=GBK" );
but, because I have told the mysql server "default-character-set=gbk", so the jdbc driver should do encoding/decoding automatically.
How to repeat:
see "description"
Suggested fix:
is it a bug?
com\mysql\jdbc\Connecter.java
move line 1969:
this.doUnicode = true; // force the issue
to line 1964, just before the line
try {
in com\mysql\jdbc\Connecter.java, line 1963, function "private void checkServerEncoding()", I guess the variable "Connecter.doUnicode" and method "Connecter.useUnicode()" indicates whether jdbc-driver should convert between unicode and mysql-server-charset. so I moved the line 1969 4 lines upper. so if the mysql-server-charset is mulity-bytes than single-byte, it can be encoding/decoding by JVM.
in fact I know little about the source code, but after this modification, the jdbc-driver works all right now.
anyway, I wish this problem could be fixed soon.
expecting your reply
yimsm@21cn.com