329
Example to store image in Oracle database
You can store images in the database in java by the help of PreparedStatement interface.
The setBinaryStream() method of PreparedStatement is used to set Binary information into the parameterIndex.
Signature of setBinaryStream method
The syntax of setBinaryStream() method is given below:
For storing image into the database, BLOB (Binary Large Object) datatype is used in the table. For example:
Let’s write the jdbc code to store the image in the database. Here we are using d:\d.jpg for the location of image. You can change it according to the image location.
Java Example to store image in the database
If you see the table, record is stored in the database but image will not be shown. To do so, you need to retrieve the image from the database which we are covering in the next page.
Next TopicRetrieving image From Oracle Database