Test Case

    public static void main(String... args) throws Exception {


        Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test;MVCC=true");
        Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST (TEST_ID LONG PRIMARY KEY, TEST_DATA TEXT);"); stat.execute("insert into TEST values(1, 'HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello')");
        ResultSet rs = stat.executeQuery("select * from test for update");
        while (rs.next()) {
            System.out.println(rs.getString("TEST_DATA"));
        }
        stat.close();
        conn.close();


    }


On 5/01/2013 6:12 AM, Ryan How wrote:
It shouldn't be. The delete is the next statement to happen, but it doesn't get there.

The code follows like so

for (Record r : getAllRecords()) {
    do stuff;
    r.delete();
}

There is only a single record. The delete does a select before deleting as part of JOOQs optimistic locking check, which is where he exception occurs.

I guess without tracing the code I'm not 100% sure what JOOQ might be doing.

I'll try and get a simple test case, first with jooq, and then just with jdbc.

Thanks, Ryan


On 4/01/2013 11:27 PM, Thomas Mueller wrote:
Hi,

Is it possible that the LOB was removed in the meantime (after running the query, but before accessing the row)?

Regards,
Thomas


On Fri, Jan 4, 2013 at 2:51 PM, Ryan How <[email protected] <mailto:[email protected]>> wrote:

    Hi,

    I'm getting a NullPointerException when trying to select a record.

    Table is:

    CREATE TABLE EMAIL_QUEUE (" +
                    "EMAIL_QUEUE_ID LONG IDENTITY," +
                    "EMAIL_DATA TEXT," +
                    "ERROR_COUNT INTEGER," +
                    "ERROR_TIME DATETIME" +
                    ");

    Connection String

    jdbc:h2:DATABASE_NAME;MVCC=TRUE;CACHE_SIZE=256000

    If I change the TEXT field to VARCHAR it works fine.

    Looks like an issue with the TEXT field? And probably MVCC ?. I
    didn't try it without MVCC. I like MVCC :)


    Thanks, Ryan


    Stack Trace

    org.jooq.exception.DataAccessException: SQL [select
    "PUBLIC"."EMAIL_QUEUE"."EMAIL_QUEUE_ID",
    "PUBLIC"."EMAIL_QUEUE"."EMAIL_DATA",
    "PUBLIC"."EMAIL_QUEUE"."ERROR_COUNT",
    "PUBLIC"."EMAIL_QUEUE"."ERROR_TIME" from "PUBLIC"."EMAIL_QUEUE"
    where "PUBLIC"."EMAIL_QUEUE"."EMAIL_QUEUE_ID" = cast(? as bigint)
    for update]; General error: "java.lang.NullPointerException"
    [50000-170]
        at org.jooq.impl.Util.translate(Util.java:649)
        at
    
org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:360)
        at
    org.jooq.impl.CursorImpl$CursorIterator.fetch(CursorImpl.java:1280)
        at
    org.jooq.impl.CursorImpl$CursorIterator.next(CursorImpl.java:1241)
        at
    org.jooq.impl.CursorImpl$CursorIterator.next(CursorImpl.java:1211)
        at org.jooq.impl.CursorImpl.fetch(CursorImpl.java:169)
        at org.jooq.impl.CursorImpl.fetch(CursorImpl.java:143)
        at
    org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:209)
        at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:258)
        at
    org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:274)
        at
    org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:413)
        at
    org.jooq.impl.TableRecordImpl.checkIfChanged(TableRecordImpl.java:325)
        at
    org.jooq.impl.TableRecordImpl.deleteUsing(TableRecordImpl.java:276)
        at
    org.jooq.impl.UpdatableRecordImpl.delete(UpdatableRecordImpl.java:83)
        at
    au.com.greatlivinghomes.buildflow.Email.sendQueuedEmails(Email.java:105)
        at au.com.greatlivinghomes.buildflow.Email$1.run(Email.java:42)
        at java.lang.Thread.run(Unknown Source)
    Caused by: org.h2.jdbc.JdbcSQLException: General error:
    "java.lang.NullPointerException" [50000-170]
        at
    org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
        at org.h2.message.DbException.get(DbException.java:158)
        at org.h2.message.DbException.convert(DbException.java:281)
        at
    org.h2.message.DbException.toSQLException(DbException.java:254)
        at org.h2.message.TraceObject.logAndConvert(TraceObject.java:368)
        at org.h2.jdbc.JdbcResultSet.getString(JdbcResultSet.java:277)
        at
    org.jooq.impl.FieldTypeHelper.getFromResultSet(FieldTypeHelper.java:455)
        at
    org.jooq.impl.FieldTypeHelper.getFromResultSet(FieldTypeHelper.java:392)
        at
    org.jooq.impl.CursorImpl$CursorIterator.setValue(CursorImpl.java:1298)
        at
    org.jooq.impl.CursorImpl$CursorIterator.fetch(CursorImpl.java:1272)
        ... 14 more
    Caused by: java.lang.NullPointerException
        at org.h2.value.ValueLobDb.getInputStream(ValueLobDb.java:293)
        at org.h2.value.ValueLobDb.getReader(ValueLobDb.java:279)
        at org.h2.value.ValueLobDb.getString(ValueLobDb.java:200)
        at org.h2.jdbc.JdbcResultSet.getString(JdbcResultSet.java:275)
        ... 18 more

-- You received this message because you are subscribed to the
    Google Groups "H2 Database" group.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:h2-database%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/h2-database?hl=en.


--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to