Trouble with remaining DB2 errors - could need some help

From: Holger Hoffstätte (holge..izards.de)
Date: Wed Jul 02 2003 - 13:25:19 EDT

  • Next message: Heiko Wenzel: "jUnit Tests"

    Mario, Andrus -

    I've spent a good deal of time yesterday and today on the DB2 adapter but
    could not make any progress with the remaining two problem reasons
    resulting in 10 overall test failures. One seems to be related to some
    primary key/sequence/constraint misbehaviour, the other to
    PreparedStatement binding and/or type mapping.
    Let me show two examples; the additional ** output is from me.

    First the uniqueness violation, from
    DataContextTst.testRollbackDeletedObject:

    [07-02 17:46:36 main] INFO QueryLogger: INSERT INTO ARTIST (ARTIST_ID,
    ARTIST_NAME, DATE_OF_BIRTH) VALUES (?, ?, ?)
    [07-02 17:46:36 main] INFO QueryLogger: [bind: 3, 'deleteTestArtist',
    NULL]
    ** object: java.lang.Integer pos: 1 type: ExtendedType
    [org.objectstyle.cayenne.access.types.DefaultType], handling
    java.lang.Integer
    ** object: java.lang.String pos: 2 type: ExtendedType
    [org.objectstyle.cayenne.access.types.CharType], handling java.lang.String
    ** object: null pos: 3 type: null
    [07-02 17:46:36 main] INFO QueryLogger: *** error.
    com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -803, SQLSTATE:
    23505, SQLERRMC: 1;CAYENNE.ARTIST
            at com.ibm.db2.jcc.c.cl.d(cl.java:1039)
            at com.ibm.db2.jcc.a.bd.k(bd.java:314)
            at com.ibm.db2.jcc.a.bd.a(bd.java:63)
            at com.ibm.db2.jcc.a.r.a(r.java:64)
            at com.ibm.db2.jcc.a.bq.c(bq.java:224)
            at com.ibm.db2.jcc.c.cm.F(cm.java:1209)
            at com.ibm.db2.jcc.c.cm.c(cm.java:1641)
            at com.ibm.db2.jcc.c.cm.C(cm.java:328)
            at com.ibm.db2.jcc.c.cm.executeUpdate(cm.java:311)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsIndividualQueries(DataNode.java:567)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:475)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:285)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:732)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:706)
            at
    org.objectstyle.cayenne.access.DataContextTst.testRollbackDeletedObject(DataContextTst.java:508)

    Notice the extremely helpful error -803 :-(
    Read all about it at:
    http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v8infocenter.d2w/report?target=mainFrame&fn=rsql0800.htm

    "SQL0803N One or more values in the INSERT statement, UPDATE statement, or
    foreign key update caused by a DELETE statement are not valid because the
    primary key, unique constraint or unique index identified by index-id
    constrains table table-name from having duplicate rows for those columns."

    Uh - I don't think so?! The test does IMHO nothing weird and actually
    fails before it gets to the interesting part (the PaintingInfo has to be
    in the DB before it can be deleted). I looked at it and really couldn't
    find anything wrong with this. Manually deleting all tables and sequences
    'just to make sure' did not help either.

    The second problem can be seen e.g. in CDOOneDep2OneTst.testReplace and
    seems to be related to BLOB and/or LONG VARCHAR insertion, although this
    should work as well:

    [07-02 17:46:46 main] INFO QueryLogger: INSERT INTO PAINTING_INFO
    (IMAGE_BLOB, PAINTING_ID, TEXT_REVIEW) VALUES (?, ?, ?)
    [07-02 17:46:46 main] INFO QueryLogger: [bind: < 02 03 04 05 >, 20, 'this
    painting sucks...']
    ** object: [B pos: 1 type: ExtendedType
    [org.objectstyle.cayenne.access.types.ByteArrayType], handling byte[]
    ** object: java.lang.Integer pos: 2 type: ExtendedType
    [org.objectstyle.cayenne.access.types.DefaultType], handling
    java.lang.Integer
    ** object: java.lang.String pos: 3 type: ExtendedType
    [org.objectstyle.cayenne.access.types.CharType], handling java.lang.String
    [07-02 17:46:46 main] INFO QueryLogger: *** error.
    com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -301, SQLSTATE:
    07006, SQLERRMC: 1
            at com.ibm.db2.jcc.c.cl.d(cl.java:1039)
            at com.ibm.db2.jcc.a.bd.k(bd.java:314)
            at com.ibm.db2.jcc.a.bd.a(bd.java:63)
            at com.ibm.db2.jcc.a.r.a(r.java:64)
            at com.ibm.db2.jcc.a.bq.c(bq.java:224)
            at com.ibm.db2.jcc.c.cm.F(cm.java:1209)
            at com.ibm.db2.jcc.c.cm.c(cm.java:1641)
            at com.ibm.db2.jcc.c.cm.C(cm.java:328)
            at com.ibm.db2.jcc.c.cm.executeUpdate(cm.java:311)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsIndividualQueries(DataNode.java:567)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:475)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:285)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:732)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:706)
            at
    org.objectstyle.cayenne.CDOOneDep2OneTst.testReplace(CDOOneDep2OneTst.java:124)

    Error -301 - who would have thought?
    http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v8infocenter.d2w/report?target=mainFrame&fn=rsql0300.htm
    says:

    "SQL0301N The value of input host variable or parameter number number
    cannot be used because of its data type.
    Explanation: A host variable or parameter in position number could not be
    used as specified in the statement because its data type is incompatible
    with the intended use of its value."

    Well let's see, we have a byte[], an int and a LONG VARCHAR - the byte[]
    is filled, the int is there and the String looks OK too. So what's the
    problem? I tried to substitute the LONG VARCHAR (which is btw only a
    couple of bytes longer than a regular VARCHAR anyway) for a CLOB - no
    dice, same error.
    According to my limited understanding of the IMHO confusing DB2
    documentation (PDFs available by request) this should work just fine. I
    guess it' likely that I've simply misunderstood or overlooked something.

    Mario, could you please have a look at these? The LIKE problems are gone
    since Andrus last patches, so the latest nightly build should be a good
    starting point. Andrus, if you want to have a look at this yourself I can
    try to let you access my machine - would be slow (128 kb uplink) but it
    might be good enough for testing.

    In case anybody else reading this has any ideas - please let us know
    what's cooking here!

    thanks
    Holger



    This archive was generated by hypermail 2.0.0 : Wed Jul 02 2003 - 13:25:24 EDT