Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

como inserir um arquivo enorme no BLOB (Oracle) sem carregar o arquivo completo na memória?


Para os que estão por aí...

Aqui está o processo para fazê-lo:
stmt.execute ("INSERT INTO my_blob_table VALUES ('row1', empty_blob())");
BLOB 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");
System.out.println("john.gif length = " + binaryFile.length());
FileInputStream instream = new FileInputStream(binaryFile);
OutputStream outstream = blob.setBinaryStream(1L);
int size = blob.getBufferSize();
byte[] buffer = new byte[size];
int length = -1;

Fonte:http://docs.oracle.com /cd/B19306_01/java.102/b14355/oralob.htm#CHDFHHHG