[ 
https://issues.apache.org/jira/browse/DERBY-3404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568593#action_12568593
 ] 

Dyre Tjeldvoll commented on DERBY-3404:
---------------------------------------

The same thing happens if you turn off autocommit and issue a commit instead of 
executing 'values 1'. I.e.

        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        Connection c = DriverManager.getConnection("jdbc:derby:db;create=true");
        c.setAutoCommit(false);
        Statement s = c.createStatement(ResultSet.TYPE_FORWARD_ONLY,
                                        ResultSet.CONCUR_READ_ONLY,
                                        ResultSet.CLOSE_CURSORS_AT_COMMIT);
        ResultSet rs = s.executeQuery("select * from sysibm.sysdummy1");
        rs.next();
        System.out.println("before ac: "+rs.getString(1));
        c.commit();
        //c.createStatement().executeQuery("values 1").close(); // auto-commit
        System.out.println("after ac:"+rs.getString(1));

But I don't really have any idea about where the connection is supposed to 
check/close result sets opened with ResultSet.CLOSE_CURSORS_AT_COMMIT

> EmbedResultSet.getString() returns wrong value after auto-commit with 
> CLOSE_CURSORS_AT_COMMIT
> ---------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3404
>                 URL: https://issues.apache.org/jira/browse/DERBY-3404
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.1.4, 10.3.2.1, 10.4.0.0
>            Reporter: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: CloseOnCommit.java
>
>
> The following code prints "null" to the console with the embedded driver:
>         Statement s = c.createStatement(ResultSet.TYPE_FORWARD_ONLY,
>                                         ResultSet.CONCUR_READ_ONLY,
>                                         ResultSet.CLOSE_CURSORS_AT_COMMIT);
>         ResultSet rs = s.executeQuery("select * from sysibm.sysdummy1");
>         rs.next();
>         c.createStatement().executeQuery("values 1").close(); // causes 
> auto-commit
>         System.out.println(rs.getString(1));
> The call to rs.getString() should perhaps have thrown SQLException, since the 
> auto-commit between next() and getString() should close the ResultSet when 
> the holdability is CLOSE_CURSORS_AT_COMMIT, I think. Anyway, the value stored 
> in SYSIBM.SYSDUMMY1 is 'Y' and not NULL, so it should definitely not return 
> null.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to