Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: java stored procedure code example

Re: java stored procedure code example

From: Jeremy Ovenden <newsposter_at_hazelweb.co.uk>
Date: Tue, 8 Oct 2002 08:15:48 +0100
Message-ID: <anu0n8$hkp35$1@ID-140241.news.dfncis.de>

"Rauf Sarwar" <rs_arwar_at_hotmail.com> wrote in message news:92eeeff0.0210041404.610d16c7_at_posting.google.com...
> "Jeremy Ovenden" <newsposter_at_hazelweb.co.uk> wrote in message
news:<ank7g3$eubun$1_at_ID-140241.news.dfncis.de>...
> >
> > I want to write these files out to a BFILE on the o/s.
> >
>
>
> 1) For starters, you can read up on Oracle's DBMS_LOB package.
>
> 2) To use Java for this... you can look up java.sql and
java.io api's
> in JavaDocs. I haven't tested this but here is sort of a
pseudo code
> that I can think of.
>
> - Open a JDBC connection to Oracle database
> Connection con = ......
> Statement stmt = con.createStatement .....
> Resultset rs = stmt.executeQuery(Select .....)
> - Create an instance of Blob
> Blob blob = rs.getBlob(column index (int) or name
(String)).
> if blob = null {return;}
> - Create an instance of BufferedInputStream
> BufferedInputStream bis =
> new BufferedInputStream(blob.getInputStream())
> - Specify a byte[] buffer size e.g. 4096
> byte[] buf = new byte[4096];
> - Create an instance of FileOutputStream
> FileOutputStream fos = new FileOutputStream(file name)
> - Read bytes from BufferedInputStream and write to
FileOutputStream
> while (bis.read into buf does not return -1)
> fos.write(write to specified file from buf)
> - Close all Streams
> bis.close()
> fos.close()
>

Thanks for the outline Rauf...I'll see what I can do with it

cheers
Jeremy

(javanewbie) Received on Tue Oct 08 2002 - 02:15:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US