This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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
Have a look at the blob and clob types. They should forfill your needs Regards Nigel
Joined: Jan 02, 2003
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
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 ]