encode image for 'setBinaryStream'

From: Georg Andersson (georg.andersson_at_swisstopo.ch)
Date: 07/26/04

  • Next message: Gerd Nachtsheim: "Re: encode image for 'setBinaryStream'"
    Date: 26 Jul 2004 07:58:34 -0700
    
    

    hi

    i like to store small images in a mssql database. i'm using the code
    below for the insert-statement.

    PreparedStatement prstmt=connection.prepareStatement("INSERT INTO
    GCP_IMAGE VALUES(?,?,?,?,?,?,?,?");
    prstmt.setLong(1,11);
    prstmt.setShort(2,(short)4);
    prstmt.setBinaryStream(3,fis,(int)file.length());
    prstmt.setString(4,"11_DRAWING.jpg");
    prstmt.setLong(5,file.length());
    prstmt.setString(6,"image/pjpeg");
    prstmt.setNull(7,Types.INTEGER);
    prstmt.setNull(8,Types.INTEGER);
                            
    prstmt.execute();

    this code returns the foolowing error:java.sql.SQLException:
    [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1:
    Incorrect syntax near '@P8'.

    after looking through many forums and web-sites, i figured out that i
    would have to encode my image in order to pass the data correctly to
    the database.

    has anybody got an idea how i'm supposed to do that?

    best regards


  • Next message: Gerd Nachtsheim: "Re: encode image for 'setBinaryStream'"

    Relevant Pages

    • Re: encode image for setBinaryStream
      ... > i like to store small images in a mssql database. ... > below for the insert-statement. ... I repeat the answer for your previous posting concerning your syntax error ...
      (comp.lang.java.databases)
    • how to get an image from a database ?
      ... i'm using a liitle script to insert images in a mssql database. ... know i'm not supposed to store images in a database, ... but the downloaded file is only 318 bytes in size and can not be ...
      (comp.lang.php)
    • Re: how to get an image from a database ?
      ... > i'm using a liitle script to insert images in a mssql database. ... > but the downloaded file is only 318 bytes in size and can not be ... // image is output to disc ...
      (comp.lang.php)