Luis,
Qual versão do Oracle que vc. está utilizando v8.1.x?

Vou te passar um trecho que eu utilizo com o 8.1.6


        File binaryFile=null;
        OracleCallableStatement cstmt=null;
        oracle.sql.BLOB blob=null;
        ...
        // Processamento, popular arquivo... pegar conexão...
        ...
        try {
                // Must use AutoCommit false
                conn.setAutoCommit(false);
                // Create the document entry in the database
                cstmt = (OracleCallableStatement)conn.prepareCall("{ ? = call
insert_blob(?) }");
                cstmt.setString(2,file_id);
                cstmt.registerOutParameter(1,OracleTypes.BLOB);
                cstmt.execute();
                // get the Blob
                blob = cstmt.getBLOB(1);
                // get the stream to write to the blob
                java.io.OutputStream outstream = blob.getBinaryOutputStream();
                // get the input stream
                FileInputStream instream = new FileInputStream(binaryFile);
                // get the optimum buffer size
                int size = blob.getBufferSize();
                byte[] buffer = new byte[size];
                int length = -1;
                // write the content from the file to the blob
                while ((length = instream.read(buffer)) != -1)
                        outstream.write(buffer, 0, length);
                // close the streams
                instream.close();
                outstream.close();
                // commit the changes on the db
                conn.commit();
        } catch (Throwable t) {
                System.out.println(t.getMessage());
        } finally {
                // close the statement -- Muito importante se vc. está utilizando
connection pool
                cstmt.close();
                // set AutoCommit back to true
                conn.setAutoCommit(true);
                // return the connection to the pool
                conn.close();
        }
}

Função no Oracle:
function insert_blob(p_file_id in  temp.file_id%TYPE) return blob
is
  p_file_content BLOB;
begin
        -- IMPORTANT:
        --   Note that the blob column DOC_CONTENT is populated with the function
        --   EMPTY_BLOB(), this is just the blob locator! The real content of the
        --   document will be updated by the caller, using a stream!
  insert into temp (file_id, file_content)
    values (p_file_id,empty_blob())
    returning file_content into p_file_content;
  return p_file_content;
end;

Eu simplifiquei as funções que eu utilizo. Então podem existir alguns erros!
Mas os conceitos estão aí!
Espero que te ajude!

[]s
Sabino
-----Original Message-----
From: Luis Henrique Bogo [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 06, 2001 3:34 PM
To: [EMAIL PROTECTED]
Subject: [java-list] Oracle / BLOB


Pessoal

Tenho um campo no banco (Oracle) do tipo Blob. Preciso gravar um arquivo
HTML nesse campo. O arquivo HTML é gerado dentro de uma classe a partir de
um objeto PrintWriter().
O problema é que não estou conseguindo converter esse objeto PrintWriter p/
o Blob, ou doretamente para o formato oracle.sql.BLOB. Alguém sabe como
fazer essa conversão?? Tem algum exemplo??

Agradeço desde já

Luis

=================================
Luis Henrique Bogo
Mestrado Eng. Produção e Sistemas
UFSC - Floripa - Brasil
=================================
Babe na ilha: www.ilhafloripa.com.br/frame.htm

"Não há stress que um bom dia de surf não cure"




------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br  -  Sociedade de Usuários Java da Sucesu-SP
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------



------------------------------ LISTA SOUJAVA ---------------------------- 
http://www.soujava.org.br  -  Sociedade de Usuários Java da Sucesu-SP 
dúvidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
para sair da lista: envie email para [EMAIL PROTECTED] 
-------------------------------------------------------------------------

Responder a