Caros estou fazendo um exemplo onde eu salvo uma imagem em banco. Estou usando um campo BLOB para o mesmo.
Em pesquisas vi que no Oracle temos q inicialmente inserir um registro Blob em branco e depois atualiza-lo com o conteúdo, no caso uma imagem .bmp.
stmt = conn.createStatement();
String sql = " SELECT SQL_IMG.nextval FROM dual";
resSet = stmt.executeQuery(sql);
if (resSet.next()) {
lngId = new Long(resSet.getLong(1));
}
stmt.execute(" INSERT INTO WSQ_IMAGEM " + " (ID" + " ,IMG"
+ " ) VALUES " + " (" + lngId + " ,empty_blob()" + " )");
strStatement = "SELECT IMG FROM WSQ_IMAGEM WHERE ID =" + lngId+ "FOR UPDATE";
rs = stmt.executeQuery(strStatement);
while (rs.next()) {
BLOB bCol = ((OracleResultSet)rs).getBLOB("IMG");
blobOutputStream = bCol.getBinaryOutputStream();
File file2Load = new File(file);
sampleFileStream = new FileInputStream(file2Load);
byte[] bBuffer = new byte[bCol.getBufferSize()];
int intBytesRead = 0;
while ((intBytesRead = sampleFileStream.read(bBuffer)) != -1) {
blobOutputStream.write(bBuffer,0,intBytesRead);
}
sampleFileStream.close();
blobOutputStream.close();
}
Da um erro na clausula “FOR UPDATE”: ERRO: ORA-00936: missing expression
Tirando a clausula acontence o seguinte erro: ORA-22920: row containing the LOB value is not locked
Alguém pode AJUDAR!!!
vlw.