resend: bug:setBytes() works wron with charsetset is sjis

resend: bug:setBytes() works wron with charsetset is sjis

am 21.01.2003 03:14:12 von charles lee

Description:
I create one table with one blob column,
use jdbc to setBytes and getBytes to the column ,and
found out the value i get from the table is not the same
as what i had set into the table.(default charset is sjis)

when i change the my.ini 's charset,do not use sjis, it works well,
what i get is what i set.

I think the blob is binary data ,should not change value with
deferent charset.


How-To-Repeat:



mysql version:
mysql Ver 12.16 Distrib 4.0.7-gamma, for Win95/Win98 (i32)
OS:
win2000 with sp2 (English version ,but customize the region language
setting)
local : japanese , default language : japanese

my.ini
[mysqld]
default-character-set=sjis


Code: dbaccess.TestBinary.java

//--begin


/**
*@author charles j lee
*/
package dbaccess;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.DriverManager;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;

class TestBinary {
public static void main(String[] args) throws
ClassNotFoundException,IOException,SQLException{
Class.forName("org.gjt.mm.mysql.Driver");
Connection connection =
DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/tes t","root","") ;
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
//Connection connection =
DriverManager.getConnection("jdbc:odbc:local_test","root","" ) ;

//clear the old data and construct table with blob column
Statement st = connection.createStatement();
try{
st.execute("drop table testtable") ;
}
catch(SQLException ex){
}
st.execute("create table testtable(object blob)") ;

//set the binary data int to the table
PreparedStatement ps = connection.prepareStatement("insert into
testtable values(?)");
//write the binary data
byte[] b = {-84,-19,0,9,115};
System.out.println("initial byte data: ") ;
printByte(b) ;

ps.setBytes(1,b) ;
ps.executeUpdate();
ps.close();


//read the binary data
ResultSet rs = st.executeQuery("select * from testtable") ;
System.out.println("Get the byte data from db") ;
if(rs.next() ){
printByte(rs.getBytes(1)) ;
}

st.close();
connection.close();
}

/**
* out put the binary array,separate with /
* @param b
*/
static void printByte(byte b[])
{
System.out.println("{") ;
for(int i = 0; i < b.length ; i ++){
System.out.print((int)b[i]);
System.out.print("/") ;

if(i 10 == 0 && i != 0){
System.out.println();
}
}
System.out.println("}");
}
}


Synopsis:
Submitter-Id:
Originator: charles j lee
Organization: home
MySQL support: [none | licence | email support | extended email support ]
Severity: [non-critical | serious | critical ]
Priority: [low | medium | high ]
Category: [mysqld, mysql client, C, PHP, PERL, ...]
Class: [ sw-bug | doc-bug | change-request | support ]
Release: mysql-3.23.38

Exectutable: [mysqld, mysqld-shareware, mysqld-nt or mysqld-opt]
Environment: windows 2000 english version ,with service pack 2
System:
Compiler: VC++ 6.0
Architecture: i

____________________________________________________________ _____
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.msn.com/cn


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13539@lists.mysql.com
To unsubscribe, e-mail

Re: resend: bug:setBytes() works wron with charsetset is sjis

am 21.01.2003 04:02:23 von Mark Matthews

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

charles lee wrote:
> Description:
> I create one table with one blob column,
> use jdbc to setBytes and getBytes to the column ,and
> found out the value i get from the table is not the same
> as what i had set into the table.(default charset is sjis)
>
> when i change the my.ini 's charset,do not use sjis, it works well,
> what i get is what i set.
>
> I think the blob is binary data ,should not change value with
> deferent charset.

You don't say what version of the JDBC driver you are using, but it
appears to be a very old one, as a bug on the client side was fixed a
few years back.

Please try Connector/J 3.0.4 from
http://www.mysql.com/products/connector-j/ and see if the bug still exists.

If you could also test if this happens with the MySQL command-line
client (mysql), that might isolate whether or not it is a server issue.

-Mark

query, sql
- --
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mark Matthews
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
/_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
<___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+LLhDtvXNTca6JD8RAozTAKC3zYnm4O4c3w4u+LQpBXAOwo11aACg n7ev
yORfQmsxv3VqgxnrTYTwr0U=
=CkOK
-----END PGP SIGNATURE-----


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13540@lists.mysql.com
To unsubscribe, e-mail