When I search the web for inserting BLOBs into Oracle database with jdbc thin driver, most of the webpages suggest a 3-step approach:
empty_blob()
Some watchouts found for the second solution
I am using ojdbc6.jar - the latest release and for the statement from 'the second solution':
BLOB blob = BLOB.createTemporary(oracleConnection, false, BLOB.DURATION_SESSION);
I have to release blob after the statement is completed - or otherwise blob is closed when session is closed (which can take long time with connection pooling).
blob.freeTemporary();
Otherwise you can see locked resources:
select * from v$temporary_lobs
Another problem with temporary BLOBs is the need to allocate temporary tablespace: as per documentation http://docs.oracle.com/cd/E11882_01/appdev.112/e18294.pdf
Managing Temporary Tablespace for Temporary LOBs Temporary tablespace is used to store temporary LOB data