problem while image insertion
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: problem while image insertion

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    problem while image insertion

    File file = new File("C:\\Users\\admin\\Desktop\\server\\flower1.jpg");
    FileInputStream fs = new FileInputStream(file);
    PreparedStatement ps = conn.prepareStatement("insert into picprop(picname,picsize,pictype,image) values(?,?,?,?)");
    ps.setString(1,"yellow");
    ps.setInt(2,89);
    ps.setString(3,"jpeg");
    ps.setBinaryStream(4,(InputStream)fs,(int)(file.length()));
    int i=ps.executeUpdate();;
    pw.println("value of i is:"+i);

    The statement[ps.setBinaryStream(4,(InputStream)fs,(int)(file.length()));] is not getting executed. what night be the reason?

  2. #2
    Join Date
    Nov 2006
    Location
    Barcelona - Catalonia
    Posts
    362

    Re: problem while image insertion

    Hi,

    Please post your code within code tags.
    What's the error you get? When you ask something you must tell us what is your problem and what you are attempting to do. We're not psychics

    I think syntactically you piece of code is right, so give us more information about the error.

    By the way, even though it is not an error it is not necessary to cast fs to InputStream. fs it's already and InputStream for being a FileInputStream.

    Regards.
    Please, correct me. I'm just learning.... and sorry for my english :-)

  3. #3
    Join Date
    Aug 2011
    Location
    West Yorkshire, U.K.
    Posts
    54

    Re: problem while image insertion

    The code looks good and runs (with minimal modifications) against an Oracle table.
    Are you getting an error thrown? Are you certain the update is being committed?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center