6 messages in com.mysql.lists.mysqlRe: binary data
FromSent OnAttachments
Thomas Kwan08 Jun 1999 14:39 
Michael Widenius08 Jun 1999 15:15 
Ying Zhang08 Jun 1999 15:31 
Thomas Kwan08 Jun 1999 15:33 
Christian Mack09 Jun 1999 12:03 
Christian Mack10 Jun 1999 10:35 
Subject:Re: binary data
From:Thomas Kwan (thom@netscape.com)
Date:06/08/1999 03:33:16 PM
List:com.mysql.lists.mysql

Michael Widenius wrote:

"Thomas" == Thomas Kwan <thom@netscape.com> writes:

Thomas> I want to add a stream of binary data (a jpeg file) via Thomas> SQL insert command. What format do I need to use when inserting the Thomas> binary data?

Thomas> thanks

Hi!

The MySQL manual tells you which characters you should escape. Manual section: 'Literals: how to write strings and numbers'

The manual talked about special characters (i.e. \,NULL,...etc). But it did not talk about unprintable character like 0x1, 0x2,...

I am using Java, and byte array (i.e. byte[]) is what I have. Should I just do the following:

byte jpgPic[] = ... String picStr = new String(jpgPic); dataStr = escapeSpecial(picStr);

s.executeUpdate("INSERT ... (" + dataStr + ")"); ...

thomas

Most MySQL API:s has also a function to escape a string (mysql_escape_string in C or the quote in perl).

Which language are you using?

Regards, Monty