sunda2010
asked on
how to store a file n retrieve a file from mysql database using jsp
sir,
I want to store into mysql database and retrieve it back from database using jsp..
wat data type should we use to store as such file in database and is there any source code available for tat in jsp?
I want to store into mysql database and retrieve it back from database using jsp..
wat data type should we use to store as such file in database and is there any source code available for tat in jsp?
A blob will work but you should consider the performance impact and space requirements over time. Another option could be to write the file to the file system and then store the file path and information about the file (if you want) in the My SQL tables.
The drawback to using the file system and tables together would be when you need to clean up the files. You will need a process that reads the table then deletes the file from the file system.
The drawback to using the file system and tables together would be when you need to clean up the files. You will need a process that reads the table then deletes the file from the file system.
ASKER
is there any source code available to display the file content which is retrieved from the database in jsp/java
I don't thinks so because you can store there any type of file, meanwhile the browser can display only some specific types of files. I would dare to say that the best you can find is a code that would return the file as a file-stream(so you can download the file).
Following link contains a very good example...
http://idevelopment.info/data/Programming/java/jdbc/LOBS/BLOBFileExample.java
http://idevelopment.info/data/Programming/java/jdbc/LOBS/BLOBFileExample.java
Shorter programs...
Write: http://www.kodejava.org/examples/279.html
Read: http://forums.sun.com/thread.jspa?threadID=5212571
Write: http://www.kodejava.org/examples/279.html
Read: http://forums.sun.com/thread.jspa?threadID=5212571
ASKER
is there any code available to store a file into mysql db?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
MySQL has BLOB field type which is used for storing files.