Overcomplicated oracle jdbc BLOB handling

前端 未结 9 1010
予麋鹿
予麋鹿 2020-12-04 18:20

When I search the web for inserting BLOBs into Oracle database with jdbc thin driver, most of the webpages suggest a 3-step approach:

  1. insert empty_blob()
9条回答
  •  日久生厌
    2020-12-04 18:35

    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

提交回复
热议问题