G
gimme_this_gimme_that
In DB2, is it possible to update a table having a BLOB using
a statement such as "SELECT MY_BLOB_FIELD FROM MY_TABLE FOR UPDATE"
Then getting the Blob and writing to the Blob's output stream ?
I'm getting an AbstractMethodError suggesting that the DB2
driver I'm using didn't implement setBinaryStream.
I can update the Blob without writing to an OutputStream,
but I'm migrating a lot of code from Oracle and I'd perfer
not to rewrite about 30 files manipulating blob/clob code.
Here is a specific example :
String sql = "select my_blob from my_table where my_table_id = 3 for
update";
con.setAutoCommit(false);
stmt = con.createStatement();
rs1 = stmt.executeQuery(sql);
if (rs1.next()) {
java.sql.Blob blob = rs.getBlob(1);
OutputStream os = blob.setBinarySteam(); // error occurs here
byte[] data = "Some data";
os.write(data);
os.close();
}
con.setAutoCommit(true);
Um.. I'm using standard DB2 type 2 drivers ...
Might there be a way to get around this by casting to
something DB2 specific (what?) and fetching the
output stream from that? Like
OutputStream os = ((DB2.SOMETHING)blob).getBinaryOutputStream();
a statement such as "SELECT MY_BLOB_FIELD FROM MY_TABLE FOR UPDATE"
Then getting the Blob and writing to the Blob's output stream ?
I'm getting an AbstractMethodError suggesting that the DB2
driver I'm using didn't implement setBinaryStream.
I can update the Blob without writing to an OutputStream,
but I'm migrating a lot of code from Oracle and I'd perfer
not to rewrite about 30 files manipulating blob/clob code.
Here is a specific example :
String sql = "select my_blob from my_table where my_table_id = 3 for
update";
con.setAutoCommit(false);
stmt = con.createStatement();
rs1 = stmt.executeQuery(sql);
if (rs1.next()) {
java.sql.Blob blob = rs.getBlob(1);
OutputStream os = blob.setBinarySteam(); // error occurs here
byte[] data = "Some data";
os.write(data);
os.close();
}
con.setAutoCommit(true);
Um.. I'm using standard DB2 type 2 drivers ...
Might there be a way to get around this by casting to
something DB2 specific (what?) and fetching the
output stream from that? Like
OutputStream os = ((DB2.SOMETHING)blob).getBinaryOutputStream();