• 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

When to use setBytes() and setBinaryStream()

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using oracle thin driver to insert a image (blob type) into database.
Which method of PreparedStatement interface should I use to insert data,
setBytes() or SetBinaryStream().
My understanding is BinaryStream also sends data in form of bytes.
Then what is the difference between these two method ?
Please let me know.
Thanks,
-Amol
[ September 01, 2003: Message edited by: Amol Desai ]
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can use the setBinaryStream, do so. It will use memory buffering to read the stream and send a block at a time to the server. This is especially important if the binary data is extremely large. However, if you are holding a reference to the entire block of bytes in memory already, then use setBytes. Get it?
Ex - if you are reading the image data from the network, or from a file, than use setBinaryStream. If you have a byte array because you already read the stream, use setBytes. However, I'd strongly suggest finding a way to "read on demand" if the files are large.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic