hi
actually uploading a file n storing it in database is part of my application.
The things i have done are i have written my jsp page and the setter and getter methods of the file...
now im stuck with database query of inserting the file into the database.i have no clue abt how to proceed with it.
can u plz help me out......
Thanks
Clearly this problem breaks down into at least 2 steps:
- Uploading the file
- Storing the file
Some web application frameworks have built in support to make uploading a file easy. Otherwise, you might consider using something like Apache Commons FileUpload:
http://commons.apache.org/fileupload/
Are for storing the file in a database, there are two common solutions to this. One is to just store the file in the file system of the server and store the path of this file (as a string) in the appropriate column in the appropriate database table.
The other approach is to store the contents of the file as data in a column. Such a column with have type BLOB (or CLOB if storing text). If your are using JDBC directly, inserting the data into the column is easy: use a PreparedStatement and setBinaryStream or setCharacterStream. For more information:
http://java.sun.com/docs/books/tutorial/jdbc/index.html