JDBC Oracle BLOB Extraction
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ramadevan_MadhuSudanan
Posted On:   Sunday, February 17, 2002 10:21 PM

Hi,
I have my PDF file stored in BLOB type in my Oracle Database.I want to retreive back the BLOB into PDF and show it in the browser.Is this possible.If so plese give me some ideas.

Re: JDBC Oracle BLOB Extraction

Posted By:   Chandra_Patni  
Posted On:   Monday, February 18, 2002 07:48 PM

It is possible. The following example illustrates it.

ResultSet rs = ...
Blob b = rs.getBlob(1);
//response.resetBuffer(); // we are still not 2.3
response.reset();
java.io.OutputStream strms = response.getOutputStream();
response.setContentType("application/pdf");
int size = 8092;
BufferedInputStream is = new BufferedInputStream(b.getBinaryStream(), size);
int n = 0;
byte bytes[] = new byte[size];
while((n = is.read(bytes, 0, size)) > 0) {
strms.write(bytes, 0, n);
}
%>
About | Sitemap | Contact