Bug #421 j-connector 3.0.7 can't conver between unicode and server-charset automatically
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
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
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