Loading ...
Sorry, an error occurred while loading the content.

creating BLOB's.. may be a off topic

Expand Messages
  • Nikolay Ivanchev
    Hello all, Blob in java.sql is interface. When recieved via ResultSet is easy to get a BLOB. But how to send a BLOB into database. I have done it via file, but
    Message 1 of 2 , Sep 1, 2003
    • 0 Attachment
      Hello all,
      Blob in java.sql is interface.
      When recieved via ResultSet is easy to get a BLOB.
      But how to send a BLOB into database. I have done it via file,
      but the situation is that I have created Image (from IconImage) and
      I want to send this Image into BLOB...
      Can some one help
      Niki
    • dj_begemot
      ... You can set blob via java.sql.PreparedStatement object: byte[] blob_val =... PreparedStatement pstmt = con.prepareStatement( INSERT INTO blob_table (ID,
      Message 2 of 2 , Sep 1, 2003
      • 0 Attachment
        --- In Firebird-Java@yahoogroups.com, "Nikolay Ivanchev"
        <nivanchev@i...> wrote:
        > Hello all,
        > Blob in java.sql is interface.
        > When recieved via ResultSet is easy to get a BLOB.
        > But how to send a BLOB into database. I have done it via file,
        > but the situation is that I have created Image (from IconImage) and
        > I want to send this Image into BLOB...
        > Can some one help
        > Niki

        You can set blob via java.sql.PreparedStatement object:


        byte[] blob_val =...
        PreparedStatement pstmt = con.prepareStatement("INSERT INTO
        blob_table (ID, BLOB_COL) VALUES (?, ? )");
        pstmt.setInt(1, 1);
        //simply
        pstmt.setBytes(2, blob_val);
        //or
        pstmt.setBinaryStream(2, new ByteArrayInputStream(blob_val),
        blob_val.length);
        //or via another setXXX method
        pstmt.execute();
      Your message has been successfully submitted and would be delivered to recipients shortly.