Subject | Re: creating BLOB's.. may be a off topic |
---|---|
Author | dj_begemot |
Post date | 2003-09-01T10:55:37Z |
--- In Firebird-Java@yahoogroups.com, "Nikolay Ivanchev"
<nivanchev@i...> wrote:
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();
<nivanchev@i...> wrote:
> Hello all,You can set blob via java.sql.PreparedStatement object:
> 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
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();