- Posted by: Ravindra Nekkalapudi
- Posted on: June 05 2003 11:32 EDT
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.
- 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
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.
For file uploads, you'll want to use one of the following:
2) Jakarta Commons FileUpload
3) Jakarta Struts 1.1
The BLOB I/O can be tricky.
Sun provides a standard Blob class: java.sql.Blob
Note: Oracle's JDBC driver requires you to use an Oracle
proprietary API for BLOB I/O.