• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to convert an object into BLOB  RSS feed

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!