This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Stroring Word Documents into MYSQL Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Stroring Word Documents into MYSQL Database" Watch "Stroring Word Documents into MYSQL Database" New topic

Stroring Word Documents into MYSQL Database

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Hello All,
I am writing a web application that would allow users to upload word Document files, I am using Hibernate to access the MySQL database. Please does any one have suggestion about how i can write the application that is how to store word documents into a MYSQL database
Charles Lyons
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Word documents are only binary data: you should be able to store them as BLOBs in an SQL database... I don't use Hibernate though, so can't suggest anything there. This is probably better off in the JDBC forum. If you want Web app advice, try the Servlets or JSP forums - as a hint, you'll want to use a form (probably HTML or JSP) with HTTP POST and a servlet to receive the POST data.

Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Charles suggestion is correct. We use BLOBs to store PDF documents but to ORACLE instead of MYSQL. I'm not sure Hibernate can handle BLOB data though I have very little experience with it. And CRUDing BLOBs usually is not as simple as INSERT, SELECT, UPDATE and DELETE. So I too would suggest plain JDBC.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Hibernate works fine with BLOB data, I use it to store images in a DB2 database.
Yuval Goldstein

Joined: Dec 27, 2006
Posts: 18
Hi Guys,
Its true you can use LOBS but actually there are some considerations not to keep the documents at the database at all but to keep them on the file-system.
If you require access to these files form several servers, you will not to store them on some storage that is available on the network (NFS, SAN, NAS)

- Inserting and reading large BLOBS (more that several MBs) suffer from low performance, sometime even horrible performance.
- The file system is already a sort of a database. It has an hierarchial structure to keep files and it is build for file access. In many cases you will want to search or access files according to their directory tree ( /users/documents/word/my.doc ).
- If you would like users to download these files, it is best you have in a 'download ready state', without having to read them by code and send them as bytes over some servlet.
- You cant look at files content when they are in the database, sometimes, this is an issue.

Many content management software solutions keep files on the file-system and file meta-data in the database (such as the file-name, author, upload time and such).

I agree. Here's the link:
subject: Stroring Word Documents into MYSQL Database
It's not a secret anymore!