MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Mark Matthews Date:March 19 2003 3:51pm
Subject:Re: how to display blob data back to text
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul DuBois wrote:
> At 5:39 -0800 3/19/03, Karthikeyan Balasubramanian wrote:
> 
>> Hi,
>>
>>   I m using the following query
>>
>> SELECT id,
>>        subject,
>>        news,
>>        date_format(date, '%m/%d/%Y %h:%i %p') AS date,
>>        author,
>>        link
>>     FROM news
>>     ORDER BY id DESC LIMIT 5
>>
>> heres my table structure
>>
>> CREATE TABLE news (                                                      
>>    id int(10) unsigned DEFAULT '0' NOT NULL auto_increment,              
>>    subject varchar(50) NOT NULL,                                         
>>    news blob NOT NULL,                                                   
>>    date datetime DEFAULT '0000-00-00' NOT NULL,                          
>>    author varchar(50) NOT NULL,                                          
>>    link varchar(150),                                                    
>>    PRIMARY KEY (id)                                                      
>>   );     
>>
>> heres the output i get in my web page
>>
>> 3 Test2 [B@1abcd9b 03/19/2003 06:28 PM karthikeyan
>> 2 Test1 [B@47b35d 03/19/2003 06:28 PM karthikeyan
>>
>> Can i tweak the query so that i can display BLOB data properly.
> 
> 
> Possibly, but you specify neither what's wrong the the values as shown
> above, or how you want them to be displayed, so I see no way to answer
> your question without additional information.
> 


Ahh, it appears you're using JDBC....If you dig down way deep in the 
JDBC spec when it talks about data type mappings, you will see that BLOB 
SQL datatypes map to java byte[]s...So, if you do a getObject() on a 
column that is a BLOB, you won't get a String, you'll get a byte[]...If 
you try and use this byte[] as a String, java prints out the address of 
it, like  '[B@1abcd9b'.

You should be using getString() if what you really want is a String. 
Alternatively, use the TEXT types in MySQL, which have many of the same 
properties of a BLOB, but are treated as text, not binary data.

	-Mark


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

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

     __  ___     ___ ____  __
    /  |/  /_ __/ __/ __ \/ /  Mark Matthews <mark@stripped>
   / /|_/ / // /\ \/ /_/ / /__ 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+eJHttvXNTca6JD8RAhNfAJ9z03ijjCHNYsdpl90RXtTGVQz3kACgswOU
ysLhcd6XpWtCNb5h5H5TidE=
=qGYa
-----END PGP SIGNATURE-----

Thread
how to display blob data back to textKarthikeyan Balasubramanian19 Mar
  • Re: how to display blob data back to textPaul DuBois19 Mar
    • Re: how to display blob data back to textMark Matthews19 Mar