2 Replies Latest reply: Jun 25, 2007 2:55 PM by 807605 RSS

    SQL UPDATE does not work

    807605
      Hey Guys,

      I have an update sql query which does not work with PreparedStatement object. Heres the code snippet:

      PreparedStatement pstmt;
      int numUpd;

      pstmt = con.prepareStatement(
      "UPDATE item_articles SET dataFile=? WHERE itemID=?");
      con.setAutoCommit(false);
      pstmt.setBinaryStream(1,fis,(int)file.length());
      pstmt.setInt(2,item.id);
      numUpd = pstmt.executeUpdate();
      con.commit();

      What I am doing here is that setBinaryStream(...) will upload a file into the DB. The query executes, theres no exception thrown, but my table shows empty field for the file. Note, there are no exceptions thrown from this query.

      If I do the same thing for an INSERT statement, it works. The file gets into the DB. So , the file is there on disk, and theres no problem with it. Just that it does not work with UPDATE.....any clues ???

      thanks
      Askar