db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-5915) "Cannot close a connection while a transaction is still active" when using PreparedStatement
Date Fri, 31 Aug 2012 15:41:07 GMT

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

Rick Hillegas commented on DERBY-5915:
--------------------------------------

This behavior of Connection.close() was recently discussed in this email thread: http://old.nabble.com/Java-7-try-with-resources-%28AutoClosable%29-on-Derby-connections-with-auto-commit-off-to34248431.html#a34248431
. David's application would benefit from autocommit-on-close behavior.

It's worth repeating one of the observations which came up in that email thread: A portable
application can't make assumptions about the transactional behavior of Connection.close()
because that behavior is not specified by JDBC. That said, someone might want to write an
application which only had to run against a limited number of data stores. It could be useful
to add a knob which set Derby's Connection.close() behavior to be the same as the behavior
of some other database.
                
> "Cannot close a connection while a transaction is still active" when using PreparedStatement
> --------------------------------------------------------------------------------------------
>
>                 Key: DERBY-5915
>                 URL: https://issues.apache.org/jira/browse/DERBY-5915
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.9.1.0
>         Environment: java 1.6+windows 7
>            Reporter: David Chan
>
> create a Preparedstatement, set its parameters, then execute it. Exception throwed when
closing connection.
> 	PreparedStatement file_stmt = conn.prepareStatement(OperationSql.NEW_FILE);
>         file_stmt.setString(1, rel_path);
> 	file_stmt.setString(2, short_name);
> 	file_stmt.setInt(3, INITIAL_VERSION);
>         int inserted  = file_stmt.executeUpdate();
>         //System.out.println(inserted);
>         file_stmt.close();
>         conn.close();
> Exception:
> java.sql.SQLException: Cannot close a connection while a transaction is still active.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.checkForTransactionInProgress(Unknown
Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.close(Unknown Source)
> BTW,  I want to use Derby as desktop db  of a client application and found it is REALLY
buggy!!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message