PROBLEM RELATED TO IMAGE..

Mahesh Rawat

Total Post:11

Points:77
Posted by  Mahesh Rawat
Java 
 1504  View(s)
Ratings:
Rate this:
 i am creating web application in j2ee, and i used oracle in backend
i have insert the image in oracle by using blob datatype
problem in fetching the image from oracle
how we write the code in java to fetching the image and show in image box.
  1. Amit Singh

    Post:103

    Points:721
    Re: problem related to image..

    we use the following syntax :
    ps.setBinaryStream(int parameterIndex, InputStream x, int length)
    where ps is the object of prepared statement

    use this code
    example:

    file=new File("C:/Picture/Sun.jpg");
    fleInStream=new FileInputStream(file);

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c=DriverManager.getConnection("Jdbc:Odbc:image","scott","tiger");
    s=c.createStatement();

    ps=c.prepareStatement("insert into tblImage values(?,?)");
    ps.setInt(1,2);
    ps.setBinaryStream(2,fleInStream,(int)file.length());
    System.out.println("success");
    ps.execute();
    ps.close();
    c.close();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!