In this section , we will insert a image into a table. For inserting image, table's field (in which image will be stored) must be define as "blob".
First, Create table'inImage' in "mysql" as--
| create table inimage(id int(5)NOT NULL auto_increment,name
varchar(30), city varchar(30),image blob,PRIMARY KEY(id)) |
For inserting whole image, we have to create an 'InputStream' object from this file. And through this object and "setBinaryStream() ", we pass the binary file content to the BLOB column .
Syntax of "setBinaryStream() " --
setBinaryStream(int parameterIndex, InputStream x, int length) --->The data will be read from the InputStream as needed for "length" bytes.
insertimage.java
import java.sql.*;
|
output--
inimage table

CMD O/P
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.