Byte encoding

Hi I am trying to do something a little strange but it is necessary.

I am writing out SQL as in a .sql text file so that I can run it on a few servers. One of the fields is a jpg image that I am trying to insert into a MEDIUMBLOB. The line will end up being -:

insert into fileBlob(fileId, data) values (123, $bytedata$);

Unfortunately I cant seem to convert the bytes into something the MySQL 5 database agrees with. The table encoding is latin-1 so I triednew String(bytes,"8859_1")

but that didn't work.

Can anyone assist please?

[631 byte] By [msduk_a] at [2007-11-27 9:48:20]
# 1

A java String is not a blob.

Any normal mapping to a jpg to a text value requires that you understand exactly what the byte mapping is going to do both as a String (which you can keep a text value but not a blob) and how the database SQL will handle it.

You can start by using the export/import features of the database (not java) to import/export a jpg file. That should give you a starting point to understand what the text value in java must look like before it will work.

jschella at 2007-7-13 0:16:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...