JDBC issues with setBinaryStream an AbstractMethodError and a cast

Discussion in 'Java' started by gimme_this_gimme_that@yahoo.com, May 19, 2005.

  1. Guest

    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();
    , May 19, 2005
    #1
    1. Advertising

  2. 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)
    Lee Fesperman, May 19, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bin Xin
    Replies:
    3
    Views:
    4,507
    John C. Bollinger
    Aug 18, 2003
  2. Jeff Gaynor

    JNI -- getting AbstractMethodError

    Jeff Gaynor, May 25, 2004, in forum: Java
    Replies:
    1
    Views:
    805
    Gordon Beaton
    May 25, 2004
  3. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    4,165
    robert
    Feb 11, 2006
  4. Replies:
    2
    Views:
    5,478
  5. Oliver Wong
    Replies:
    11
    Views:
    1,008
Loading...

Share This Page