Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2002
    Posts
    22

    Unanswered: How do I retrieve CLOB data using the DB2 JDBC driver?

    How do I retrieve data from a CLOB field using the DB2 UDB v7.2 JDBC driver?

    When I use ResultSet.getString(1) I get the following exception:

    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0150E Driver not capable. SQLSTATE=HYC00

    When I use ResultSet.getClob(1) I get the following exception:

    java.lang.AbstractMethodError: COM.ibm.db2.jdbc.app.DB2ResultSet.getClob(I)Ljava/sql/Clob;


    I'm using the UDB v7.2 JDBC App driver. Following is the code fragment:

    // table testclob contains a CLOB field called name

    String sql = "select name from testclob";

    Statement stmt = conn.createStatement();

    ResultSet rs = stmt.executeQuery(sql);

    if (rs.next())
    {
    java.sql.Clob clob = rs.getClob(1);
    }

    thanks in advance
    - Garry

  2. #2
    Join Date
    Nov 2001
    Location
    Finland, Kirkkonummi
    Posts
    17
    Hello

    You might want to check db2cli.ini file. Look for the setting
    LONGDATACOMPAT in your DB alias.

    You can comment that row out by adding ; before variable.

    ;LONGDATACOMPAT = 1

    If it is not this then I am sorry to say that I don't have other clues.

    Vesku

  3. #3
    Join Date
    Apr 2002
    Posts
    22
    Thanks for the suggestion Vesku.

    Unfortunately doing this didn't solve my problem. I'm still getting the aforementioned exceptions.

    To clarify, I'm using JDK 1.3.1 with the UDB v7.2 App Driver.

    Anyone any other suggestion please?

  4. #4
    Join Date
    May 2002
    Posts
    1

    Same problem

    I've had the very same problem. Any thoughts would be appreciated.

    Eric

    Originally posted by gfcronin
    Thanks for the suggestion Vesku.

    Unfortunately doing this didn't solve my problem. I'm still getting the aforementioned exceptions.

    To clarify, I'm using JDK 1.3.1 with the UDB v7.2 App Driver.

    Anyone any other suggestion please?

  5. #5
    Join Date
    Nov 2002
    Posts
    7
    We managed to get the data out, but it was really ugly. We tried to get an ASCII stream but that didn't work so we did it with a binary stream. Here is some sample code:

    byte[] b = null;
    StringBuffer sbuf = null;
    int i;

    InputStream is = rs.getBinaryStream(2);
    if(is != null)
    {
    sbuf = new StringBuffer(8000);
    b = new byte[2000];

    numRead = is.read(b);
    while(numRead > 0)
    {
    for(i = 0; i < numRead; ++i)
    {
    sbuf.append((char)b[i]);
    }

    numRead = is.read(b);
    }

    is.close();

  6. #6
    Join Date
    Oct 2002
    Location
    Toronto, Canada
    Posts
    12
    you have to set the jdbc to 1.2
    if you are in unix

    . ~/sqllib/java12/usejdbc2

    if you are in windows, there is a little bat file that you need to run.

    before you execute it....

    jdbc 1.1 does not support clobs.... also make sure that you are at the correct level of java 1.2 at least maybe 1.3
    Paul
    www.dbmsguy.com

  7. #7
    Join Date
    Oct 2002
    Location
    Pune (India)
    Posts
    9
    Use DISABLE UNICODE=1 in the db2cli.ini file and bind your Utilities thru CCA (Client Configuration Assistant). It should solve your problem.

    Sujit.

  8. #8
    Join Date
    Aug 2002
    Posts
    12

    Smile

    and You should do from the CLP:
    ( if you want to use Java storedprocs& UDFs.with jdbc 2.0)

    >db2set DB2_USE_JDK12=1

    I thought there was a Java Sample which handles CLOB,
    but I cannot remember.... check somewhere in c:\sqllib\samples

    http://www-3.ibm.com/software/data/db2/java/
    will tell you some limitation about clob and jdbc driver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •