RESPONDER UNA PREGUNTA

Si para responder la pregunta, crees necesario enviar un archivo adjunto, puedes hacerlo a traves del correo [email protected]

    Pregunta:  44476 - UTILIZAR LOS TIPOS BLOB DE ORACLE
Autor:  Eva Fernandez
Estoy intentando hacer una aplicación en java que se descarga un archivo .zip almacenado en una columna tipo Blob de oracle. He encontrado el siguiente código, pero me dice que la clase BLOB no está definida, es decir, no la encuentra. ¿me podeis ayudar?

PreparedStatement pst = null;
sSql = "INSERT INTO FOTO (ID_OBJETO,IX_FOTO,DESC_FOTO,IMG_FOTO) VALUES (?,?,?,?)";
pst = con.prepareStatement(sSql);
pst.setString(1,sNumObjeto);
pst.setString(2,sId);
pst.setString(3,sDescrip);

File fi = new File(RUTA DE DONDE SE GUARDE EL FICHERO EN EL SERVIDOR);

FileInputStream fis = new FileInputStream(fi);

byte[] zipped = new byte[ (int) fi.length()];
fis.read(zipped);

BLOB blob = BLOB.createTemporary(con, true, BLOB.DURATION_SESSION);

OutputStream blob_os = blob.getBinaryOutputStream();
blob_os.write(zipped);
blob_os.flush();
pst.setBlob(4, blob);

int i = pst.executeUpdate();
con.commit();
pst.close();
fis.close();
fi.delete();


Nombre
Apellidos
Correo
Comentarios