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.
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
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 / AmazonAmazon UK )
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
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).