By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,756 Members | 1,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,756 IT Pros & Developers. It's quick & easy.

JDBC issues with setBinaryStream an AbstractMethodError and a cast

P: n/a
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();

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
gi*******************@yahoo.com wrote:

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 ...


Sounds like DB2 doesn't support JDBC 3 java.sql.Blob in those drivers. Before JDBC 3,
you couldn't change the contents of a Blob.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
================================================== ============
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.