5 messages in com.mysql.lists.javaRe: Binary output on SHOW FULL PROCES...
FromSent OnAttachments
Alan R Williamson15 Feb 2006 10:07 
Mark Matthews15 Feb 2006 11:24 
Alan R Williamson15 Feb 2006 12:54 
Paul Palaszewski15 Feb 2006 16:19 
Alan R Williamson20 Feb 2006 03:44 
Subject:Re: Binary output on SHOW FULL PROCESSLIST
From:Mark Matthews (ma@mysql.com)
Date:02/15/2006 11:24:11 AM
List:com.mysql.lists.java

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

Alan R Williamson wrote:

[prewarning: this may be the wrong list]

I have just moved up to MySQL5 and while i would like to say it was a painless operation, i can't. One of the wee things that has hit me is when i run:

"SHOW FULL PROCESSLIST"

The JDBC driver (mysql-connector-java-3.1.12-bin.jar) is telling me that the data type for the "Info" column is binary. But when i run it from a mysql-console it looks just fine as text.

Alan,

The MySQL console doesn't care about metadata. It just spits out whatever it finds as data to the console, ignoring types and character sets.

Since JDBC can't treat byte[] as String (since Java is unicode, and typesafe as well), the JDBC driver _cares_ about metadata, and thus will return different types based on what metadata the server returns.

If I look at the metadata returned for this field, I see that the server says that it is:

FIELD_TYPE_VAR_STRING, with a character set of "binary", with the isBinary column flag set. Unfortunately, this is the _exact_ same "fingerprint" the server uses for the BINARY/VARBINARY type, which by the JDBC spec maps to byte[]. Thus if you use ResultSet.getObject(), you will get the byte[] that represents the data. If you pass this to something that .toStringifies it, you'll get the array "address", like [B@nnnnnn on most JVMs.

If you use .getString() on the value, the driver does the right thing, which in _general_ if you're going to pass something to be stringified with JDBC, you should use ResultSet.getString().

-Mark -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD83/ytvXNTca6JD8RAsZ+AJ9YepKRs/rJ5/iWvLO9dA7ffeP2cwCgxN8n VdwUzvwkBUir/9eNmYdbN/Y= =h9tF -----END PGP SIGNATURE-----