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

Kathey Marsden commented on DERBY-5915:
---------------------------------------

Thank you David for trying Derby with your application.  I appreciate you 
taking time to provide  feedback on portability issues when migrating your 
application to Derby.  Sometimes even when different database products adhere 
to standards there are differences in behavior because as in the case of 
Connection.close() the behavior for open transactions can be implementation 
defined.
http://docs.oracle.com/javase/6/docs/api/java/sql/Connection.html#close()


I think that you are right that  if the application has  not changed the auto 
commit behavior, you should not need to commit before closing the connection.  
Can you provide the output of System.out.println("getAutoCommit" + 
conn.getAutoCommit()); when the exception occurs to make sure that auto commit 
is set as you suspect. . Also the SQL you are executing (OperationSql.NEW_FILE) 
might be helpful to try to reproduce and understand your issue.  Also are you 
using the embedded or network driver?  If there is a bug here, the  best thing 
will be to attach a stand alone java program to this issue.








                
> "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

Reply via email to