Hi Friends,
How do i store a Micosoft Word document inside a database using BLOB?.
Database: IBM DB2 UDB 7.1
Column Type: BLOB
The requirement is that the user selects word file in the browser. Once he clicks the Submit, the file has to be stored in the database. I required to write a servlet to handle this.
Thanks
ravindra
Discussions
Web tier: servlets, JSP, Web frameworks: How to store a Word file inside a database using the BLOB ?.
-
How to store a Word file inside a database using the BLOB ?. (2 messages)
- Posted by: Ravindra Nekkalapudi
- Posted on: June 05 2003 11:32 EDT
Threaded Messages (2)
- How to store a Word file inside a database using the BLOB ?. by Web Master on June 05 2003 13:12 EDT
- file upload, http, web applications by Sean Sullivan on June 05 2003 14:41 EDT
-
How to store a Word file inside a database using the BLOB ?.[ Go to top ]
- Posted by: Web Master
- Posted on: June 05 2003 13:12 EDT
- in response to Ravindra Nekkalapudi
You need to upload the file via a form using enctype="multipart/form-data". Your servlet can then grab the word doc as a byte[] or binary stream and insert it into your blob field.
Struts really makes the upload part easy...if your not using Struts, it may be worth it just for this one feature. There are other api's out there that handle form uploads too..struts just happens to be the one i use. If you would like more detail on doing this with struts, email me at notsew_nekia at yahoo dot com.
Im doing the very same thing on a project now. -
file upload, http, web applications[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: June 05 2003 14:41 EDT
- in response to Ravindra Nekkalapudi
For file uploads, you'll want to use one of the following:
1) http://www.servlets.com/cos/index.html
2) Jakarta Commons FileUpload
3) Jakarta Struts 1.1
package: org.apache.struts.upload
The BLOB I/O can be tricky.
Sun provides a standard Blob class: java.sql.Blob
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Blob.html
Note: Oracle's JDBC driver requires you to use an Oracle
proprietary API for BLOB I/O.