Link to home
Start Free TrialLog in
Avatar of sunda2010
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?
Avatar of TeazerMD
TeazerMD

Hello, you would need to create a field in your database for that.
MySQL has BLOB field type  which is used for storing files.
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.
Avatar of sunda2010

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).
is there any code available to  store a file into mysql db?
ASKER CERTIFIED SOLUTION
Avatar of siddagrl
siddagrl
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial