How to upload and retrieve BLOB Datatypes to/from database?
By sakthi on Jan 27, 2006
It is very common among web applications to upload files like Images, PDF’s into database and retrieve them when user needs to view those files. This Creator 2 Project zipfile available here demos this task.
- Download and extract the project zip into a directory
Create a table DEMO_BLOB in PointBase Order datasource i.e., Invoke View Data on Order Datasource in Servers window. Copy & paste this SQL and click RunQuery button to execute the command. This SQL creates the required table in PointBase sample database PBPUBLIC schema.
IDCOL INTEGER IDENTITY (1,1) PRIMARY KEY,
Open the project in Creator and Click on Run Main Project (aka Green Arrow) toolbar button
Click Browse and choose an image file. A few sample images files are available in the project at $Demo_Blob/web/sample_images folder
Click Upload Button to updload this into database. It also retrieves back all the images in this database table and displays using in a table component.
What’s wired in this project:
DisplayServlet that pulls the image for a given ID.
Upload Button action handler inserts a row with the imagefile into database table DEMO_BLOB.
Image component in the table uses the DisplayServlet URL to retrieve the image from database
Servets and servlet-mappings have been declared in WEB-INF/web.xml