db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel John Debrunner (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3115) With embedded driver and autocommit, when closing a connection, updates on updatable result set are lost, unless result set is closed
Date Tue, 20 Nov 2007 06:10:43 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543789

Daniel John Debrunner commented on DERBY-3115:

To really follow the JDBC spec I think what is needed is:

 3) If Connection.close() leads to a statement being completed (JDBC 4 section 10.1) then
a commit should be triggered.
      If Connection.close() does not lead to a statement being completed then no commit is
triggered, if a transaction is active an exception is thrown following SQL Standard 17.3 GR

This approximates 1a) but is strictly not the same, and thus simply putting a commit in Connection.close()
is not the same. 

This may be somewhat further confused by the rules for statement completion have changed from
JDBC 3 to JDBC 4.
JDBC 3 includes that a statement is completed when "another Statement object is executed on
the same connection" (section 10.1),
but this line was removed in JDBC 4.

Thus this code behaves differently in JDBC 3 & 4

ResultSet rs1 = ps1.executeQuery();
ResultSet rs2 = ps2.executeQuery();

JDBC 3 will commit & close rs1 when rs2 is created
JDBC 4 seems to indicate that both those ResultSets are open and can be used within a single
auto-committed transaction. The transaction will be committed when rs1 or rs2 closes, whichever
happens first.

Note that Derby implements JDBC 3 in that it performs a commit (in auto-commit) on any execution
within the connection. I wonder if JDBC 4 intended to make this change in behaviour.

> With embedded driver and autocommit, when closing a connection, updates on updatable
result set are lost, unless result set is closed
> -------------------------------------------------------------------------------------------------------------------------------------
>                 Key: DERBY-3115
>                 URL: https://issues.apache.org/jira/browse/DERBY-3115
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions:
>            Reporter: Dag H. Wanvik
>         Attachments: Main.java
> With autocommit, if an application neglects to close the result set
> and/or the statement, the closing of the connection will lose any
> updates performed via an updatable result set.
> If autocommit is false, SQL state 25000 invalid transaction state will
> be thrown, however.
> The JDBC standard requires that statements be closed when the
> connection is closed, cf.  JDBC 4, section 9.4.4: "All Statement
> objects created from a given Connection object will be closed when the
> close method for the object is called."  For updatable result sets,
> closing the statement would lead to a closing of the result set, and
> hence a commit of the updates.
> For the network client it works as expected.

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

View raw message