• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to use getBinaryOutputStream()

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to use getBinaryOutputStream() to retrieve gif file from oracle and display that gif file in the browser.
will any one help me.
I have written this coding. but i am not able to display the gif file in the browser.
sample code:
-----------
java.sql.ResultSet rset = stmt.executeQuery ("select picture from test1 where name='test2' for update");
BLOB blob=null;
int count=0;
while(rset.next ())
{
count++;
blob=((oracle.jdbc.driver.OracleResultSet)rset).getBLOB(1);
out.println(blob.length());
Object obj;
OutputStream ostream = blob.getBinaryOutputStream ();
java.io.ObjectOutputStream objs =new java.io.ObjectOutputStream(ostream);
objs.writeObject(obj);
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By using an ObjectOutputStream you are serializing a Java object out - not the same as writing a byte array representing the gif image. You also appear to be writing to the blob, not to the servlet response.
Seems to me you should read a byte array from Oracle, use the array size to set the response Content-Length then write it to the response output stream. Be sure to also set the Content-Type.
Bill

------------------
author of:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic