jsp-develop.de presents:

BLOB's und mySQL

von Marc,  30.05.2001 14:38:18

Bei mySQL können Binärdaten nicht ohne weiteres in BLOB's gespeichert werden, so müssen laut Dokumentation bestimmte characters umgewandelt werden:

»If you want to insert binary data into a BLOB column, the following characters must be represented by escape sequences:

NUL ASCII 0. You should represent this by `\0' (a backslash and an ASCII `0' character).
\ ASCII 92, backslash. Represent this by `\\'.
' ASCII 39, single quote. Represent this by `\''.
" ASCII 34, double quote. Represent this by `\"'. «

Ein Weg um Binärdaten in BLOBs zu speichern ist die Umwandlung in Base64 (Klassen dazu gibt es wie Sand am Meer), die codierten Daten können dann einfach mit einem PreparedStatement mittels setString() eingetragen werden.
Nach Auslesen der Binärdaten natürlich nicht das Decodieren vergessen....
URL dieses Beitrags:
http://www.jsp-develop.de/forumbeitrag/view/74/