Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing file in oracle databse

 
Prashant Satarkar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have to store files, like .html, .gif, .jpg, .txt etc in the database. I mean not only the content, but the entire file with name.
Also, I want to retrieve it with name and full content.
Any idea how exactly will I be able to do it?
Should I use FileInutStream and convert it to ByteArrayInputStream and store it as bytes[] ?
Then, again convert byte array to file input stream and file object?
Thanks in advance,
Prashant
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the blob and clob types. They should forfill your needs
Regards
Nigel
 
Prashant Satarkar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all thanks Nigel. I think my qs was very brief. i have to store images .gif/.jpg in the database using Java.
I am exploring the following options:
1. Converting the images to Byte Array and storing in the CLOB field in Database. Its not ahppening as it gives teh following error: "ORA-01461: can bind a LONG value only for insert into a LONG column".
If I try inserting a string "abc".getBytes(), its not giving any problem and i am able to insert it.
2. The other option is using BLOB. I am trying that out but have no idea how to do this? Please let me know how can I use the BLOB field and insert images .gif/.jpg into it using Java
Thanks,
Prashant
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prashant,
It is better to use BLOB. Blob is meant for binary data (which is what you have) while clob is meant for character data.
Sun has a tutorial that explains it.
[ March 24, 2004: Message edited by: Jeanne Boyarsky ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic