First, you should get it working without Camel (writing a BLOB into the
database) if you have problems. I think the instructions in [1] will help
you. I think you have to do develop something similar like this one:

String cmd = "CREATE TABLE my_blob_table (x VARCHAR2 (30), c BLOB)";
stmt.execute (cmd);

stmt.execute ("INSERT INTO my_blob_table VALUES ('row1', empty_blob())");

cmd = "SELECT * FROM my_blob_table WHERE X='row1' FOR UPDATE";
ResultSet rset = stmt.executeQuery(cmd);
rset.next();
BLOB blob = ((OracleResultSet)rset).getBLOB(2);

File binaryFile = new File("john.gif");
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = blob.setBinaryStream(1L);
int size = blob.getBufferSize();
byte[] buffer = new byte[size];

int length = -1;
while ((length = instream.read(buffer)) != -1)
   outstream.write(buffer, 0, length);
instream.close();
outstream.close();
conn.commit();


I think the easiest solution for your requirement is to implement a bean
(DAO style) which may use the JDBCTemplate from Spring and implement the
code by yourself. As you can see, handling BLOB and CLOB is much more
difficult than the other datatypes.

[1]
http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/oralob.htm#i1058035

Best,
Christian

Reply via email to