problem related to image..

Total Post:11

Points:77
Java 
 1704  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. 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();

      Modified On Mar-29-2018 03:39:54 AM

Answer

NEWSLETTER

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