| Author |
Storing in BLOC column.
|
Alex Marks
Ranch Hand
Joined: Sep 12, 2005
Posts: 31
|
|
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.
|
Before I come here, I am confused about Servlet/JSP. Ater I come here, I am more confused about it, but in systematically.
|
 |
Avi Abrami
Ranch Hand
Joined: Oct 11, 2000
Posts: 1112
|
|
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
Joined: Sep 12, 2005
Posts: 31
|
|
|
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!
|
 |
Shivakumar Mallikarjun
Greenhorn
Joined: Jul 08, 2005
Posts: 4
|
|
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
Joined: Sep 12, 2005
Posts: 31
|
|
|
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
Joined: Sep 12, 2005
Posts: 31
|
|
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
Joined: Jul 08, 2005
Posts: 4
|
|
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.
|
 |
 |
|
|
subject: Storing in BLOC column.
|
|
|