• 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

Storing in BLOC column.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,
I am using a HTML form to upload a file(picture/image), at the server-side, I'd like to store it in BLOB column. However,I dont know how to store the file in such column. Anyone,please help me to solve this problem.
Thank you in advance and looking for your replies ASAP.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alex,
Different databases have different ways of dealing with BLOB columns, so I don't think anyone will be able to answer your question until you tell us which database you are using.

Good Luck,
Avi.
 
Alex Marks
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Oracle database, I have seen some solutions but I am not so sure how to do it ! Would you please help me? Thank you in advance!
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can insert file data into BLOB column in Oracle DB by first reading the file as ByteStream & later inserting that into BLOB column.
One more thing you can't insert data into BLOB/CLOB column by Stored Procedures/Functions, you have to embed the SQL in your Java application.
Hope this serves your purpose.
 
Alex Marks
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give me the piece of code how to convert the file to the stream of byte ? Thank you in advance
 
Alex Marks
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shivakumar,
As you said, first i need to read the file as ByteStream, do i need to store the file temporary first? then i read or i can read directly?
 
Shivakumar Mallikarjun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code to read word & pdf files in byte format, presume that pdfdata is the form field name which contains file data

if(pdfdata != null){
byte byteData[] = pdfdata;

}
After this you can use pdfdata in INSERT SQL query statement to insert the data into table.
Hope this helps you.
reply
    Bookmark Topic Watch Topic
  • New Topic