Here is the sample code
import java.io.*;
import java.sql.*;
public class ImageStoreDatabase{
public static void main(
String args[]){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:sid","scott","tiger");
PreparedStatement pstmt=con.prepareStatement("insert into image values
(?,?)");
FileInputStream fis=new FileInputStream("file name");
pstmt.setInt(1,21);
pstmt.setBinaryStream(2,fis,fis.available());
pstmt.executeUpdate();
}catch(Exception e){}
finally{
//pstmt.close();
}
}
}
and the table of the structure goes like this
create table image(id number(5),image blob);