• 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 convert an object into BLOB

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an XML file (or say any file)
I create an FileInputStream Object with it
Now I have to store this object in to database
I don't know whether I have to use CLOB or BLOB but
suppose I m using BLOB then how to convert it inot a BLOB object
do we have to use
setBlob(int x,Blob y)?
if yes then do we have to give FileInputStream Object as an argument for Blob object?
or is there any other alternative?
 
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gaurav,
That won't work, because your FileInputStream is attach to some external file on your harddrive. Let say you do save the FileInputStream object in the database, and reconstruct the object from the DB in your program at some later time in the future. Can you guaranty that the external file still exist and is in the same location?
A better approach is to read in the XML data, and store it in some application object. This object should then be serialized and stored in a BLOB or CLOB.
-Peter
 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one please tell how can we store our file in a BLOB or CLOB
setClob(int x,Clob y)
is a function
so wht argument shoud go for second parameter
I m still confused

Originally posted by Peter Tran:
Gaurav,
That won't work, because your FileInputStream is attach to some external file on your harddrive. Let say you do save the FileInputStream object in the database, and reconstruct the object from the DB in your program at some later time in the future. Can you guaranty that the external file still exist and is in the same location?
A better approach is to read in the XML data, and store it in some application object. This object should then be serialized and stored in a BLOB or CLOB.
-Peter


 
knowledge is the difference between drudgery and strategic action -- 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