problem related to image..

Total Post:11

Points:77

Java 
 1935  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. 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

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.